Skip to content

tmap code fails on 'Run code' but works on tutorial load or 'Start Over' #484

@andysouth

Description

@andysouth

System details

Output of sessioninfo::session_info()():

R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 10240)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] learnr_0.10.1.9008    afrilearnr_0.0.0.9000 devtools_2.3.2        usethis_2.0.0        

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6           later_1.1.0.1        compiler_4.0.3       prettyunits_1.1.1   
 [5] remotes_2.2.0        tools_4.0.3          testthat_3.0.0       digest_0.6.27       
 [9] pkgbuild_1.1.0       pkgload_1.1.0        jsonlite_1.7.2       memoise_1.1.0       
[13] evaluate_0.14        lifecycle_0.2.0      rlang_0.4.10         shiny_1.6.0         
[17] cli_2.2.0            rstudioapi_0.13      curl_4.3             yaml_2.2.1          
[21] xfun_0.20            fastmap_1.1.0        withr_2.4.1          knitr_1.31          
[25] htmlwidgets_1.5.3    desc_1.2.0           fs_1.5.0             rprojroot_2.0.2     
[29] glue_1.4.2           R6_2.5.0             processx_3.4.4       fansi_0.4.1         
[33] rmarkdown_2.6        sessioninfo_1.1.1    callr_3.5.1          purrr_0.3.4         
[37] magrittr_2.0.1       promises_1.1.1       ps_1.4.0             ellipsis_0.3.1      
[41] htmltools_0.5.1.9000 assertthat_0.2.1     xtable_1.8-4         mime_0.9            
[45] renv_0.12.5          httpuv_1.5.5         markdown_1.1         crayon_1.4.0 

Example application or steps to reproduce the problem

https://andysouth.shinyapps.io/test-tmap-view/
https://github.com/afrimapr/afrilearnr/blob/main/inst/tutorials/test-tmap-view/test-tmap-view.Rmd

library(learnr)
knitr::opts_chunk$set(echo = FALSE)

library(tmap)
data("World")
tmap_mode("view")
tm_shape(World) +
    tm_polygons("HPI")

Describe the problem in detail

The chunk above - the Hello World ! example from tmap, with tmap_mode(“view”) added, works when the tutorial is loaded, or on 'Start Over' or when run from console, but fails (with $ operator is invalid for atomic vectors) when ‘Run Code’ is pressed

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