wch / webshot

Take screenshots of web pages from R

Home Page:http://wch.github.io/webshot/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webshot generates warning message if v

warnes opened this issue · comments

When webshot is called with the cliprect parameter set to "viewport" it generates the warning message:
Warning: 'length(x) = 4 > 1' in coercion to 'logical(1)'.

Example

webshot::webshot("http://r-project.org", cliprect = "viewport")

This appears to be generated from these lines in mapshot:

webshot/R/webshot.R

Lines 191 to 204 in e5df3d0

cliprect <- lapply(cliprect, function(x) {
if (is.character(x)) {
if (x == "viewport") {
x <- c(0, 0, vwidth, vheight)
} else {
stop("Invalid value for cliprect: ", x)
}
} else {
if (!is.numeric(x) || length(x) != 4) {
stop("'cliprect' must be a 4-element numeric vector or a list of such vectors")
}
}
x
})

A simple solution would be to check for cliprect=="viewport" earlier in the function.