I am hoping someone can shed light on this error I've started encountering when trying to save R notebooks after using mapview(). I have not been able to find other reports of this problem via Google searching; I apologize if I've missed something obvious.
Rstudio returns an error when saving the *.Rmd file if the file includes (or ever included) mapview output. The *.Rmd file saves as expected, but RStudio is unable to save the *.nb.html file.
The error shows up in a yellow bar at the top of the source window and says the following:
Error creating notebook: 'mode' for the clipboard must be 'r' or 'w'".
(I have included a screenshot of the error at the end for context).
Here is the entirety of a minimal reproducible example .Rmd file that gives me this error:
> ---
> title: "R Notebook"
> output: html_notebook
> ---
>
> ```{r}
> library(mapview)
>
> # Dummy data
> x <- c(-112, -111, -110)
> y <- c(40, 41, 42)
>
> mapview(x,y)
> ````
Additional Information
- The mapview map is rendered correctly inline in RStudio (see image below).
- I am able to generate an html document with the mapview map if I change the output to "html_document" instead of html_notebook and then knit to html. However, I really prefer using the notebook format and have been able to include mapview maps in notebooks in the past.
- After receiving the error, the working directory changed (e.g. typing getwd() in the console) to a directory within .Rproj.user instead of being the project directory itself. In this case it was changed to "../.Rproj.user/shared/notebooks/E09E316C-example01/1/s/lib".
- The error persists even if I delete the mapview command, clear the chunk output, and try re-saving. Deleting the .Rproj.user directory so that it regenerates allows me to save the now mapview-free notebook.
- I have no problems saving R notebooks for any .Rmd files that do not include a mapview command.
Here are my session details:
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] mapview_2.7.8
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 RColorBrewer_1.1-2 compiler_4.0.0 base64enc_0.1-3 class_7.3-17
[6] tools_4.0.0 uuid_0.1-4 digest_0.6.25 jsonlite_1.6.1 satellite_1.0.2
[11] evaluate_0.14 lifecycle_0.2.0 lattice_0.20-41 viridisLite_0.3.0 png_0.1-7
[16] rlang_0.4.6 DBI_1.1.0 crosstalk_1.1.0.1 yaml_2.2.1 xfun_0.14
[21] e1071_1.7-3 stringr_1.4.0 raster_3.1-5 knitr_1.28 systemfonts_0.2.2
[26] gdtools_0.2.2 htmlwidgets_1.5.1 stats4_4.0.0 classInt_0.4-3 leaflet_2.0.3
[31] grid_4.0.0 webshot_0.5.2 svglite_1.2.3 sf_0.9-3 R6_2.4.1
[36] rmarkdown_2.2 leafpop_0.0.5 sp_1.4-2 magrittr_1.5 scales_1.1.1
[41] codetools_0.2-16 htmltools_0.4.0 units_0.6-6 mime_0.9 colorspace_1.4-1
[46] brew_1.0-6 KernSmooth_2.23-17 stringi_1.4.6 munsell_0.5.0 leafem_0.1.1
[51] markdown_1.1
I am using the most recent version of Rstudio Desktop IDE (1.3)
Thank you for any guidance you might be able to provide on either the problem or additional troubleshooting that might be helpful!