这是indexloc提供的服务,不要输入任何密码
Skip to content

rendering a map fails if running inside Rscript #78

@behrica

Description

@behrica

To reproduce:

 Rscript --vanilla -e "pdf();library(tmap);data(Europe);tm_shape(Europe)+tm_polygons(col='pop_est');dev.off()"
Error in bb(mshp_raw) : Incorrect x argument
Calls: <Anonymous> -> print.tmap -> print_tmap -> bb
In addition: Warning message:
In is.na(x) : is.na() applied to non-(list or vector) of type 'S4'
Execution halted

In reallity the bb() function fails, so the easiest reproducible way (under Linux), is this:

Rscript --vanilla -e "devtools::install_github('mtennekes/tmap',subdir='pkg');library(tmap);data(Europe);;pdf();bb(Europe);dev.off()"

or without the pdf():

Rscript --vanilla -e "library(tmap);data(Europe);bb(Europe)"

I tried the CRAN version as well, and same problem.

It works by execution R from the commandline:

R --vanilla -e "devtools::install_github('mtennekes/tmap',subdir='pkg');library(tmap);data(Europe);Europe;pdf();bb(Europe)"

I tried as well something similar with ggplot2, and it does work with RScript:

Rscript --vanilla -e "pdf();library(ggplot2);qplot(mpg, wt, data = mtcars);dev.off()"

My use case is to use the function servr::jekyll() to convert a bunch of Rdm file to html.
And this function shells out and executes knitr via Rscript and in there the rendering of tmap fails.

I was trying various versions of tmap, and tried it as well in a brand new Docker container, but always the same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions