I'm trying out the new R notebooks feature in Rstudio, but the chunks are not evaluating. When I preview the minimal example featured in rstudio (when you start a new file) the window says explicitly;
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.
However there is no "run" button in the preview and the code does not evaluate. This is what I get basically (even if I place eval = TRUE in the chunk options).
I have been all over but I can still not get the chunks to evaluate. When using a normal rmarkdown document, it evaluates with no problem. Do I have to place a specific htmlwidget or something?
Here are my specs:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tse.sql_0.1.0 memisc_0.99.7-1 MASS_7.3-45 lattice_0.20-34 foreign_0.8-67 magrittr_1.5 ggplot2_2.2.0
[8] inegiR_1.2.0 dplyr_0.5.0 tse.utils_0.1.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 knitr_1.14 munsell_0.4.3 colorspace_1.2-7 R6_2.2.0 stringr_1.1.0 plyr_1.8.4
[8] tools_3.3.2 grid_3.3.2 gtable_0.2.0 DBI_0.5-1 htmltools_0.3.5 lazyeval_0.2.0 yaml_2.1.13
[15] assertthat_0.1 digest_0.6.10 tibble_1.2 formatR_1.4 base64enc_0.1-3 evaluate_0.10 rmarkdown_1.1
[22] stringi_1.1.2 scales_0.4.1 XML_3.98-1.4 jsonlite_1.1 zoo_1.7-13
Using Rstudio 1.0.44 and these options:
As a feature (or bug), chunks in Notebooks do not run when you click 'Preview' but rather as you evaluate each chunk (in the course of writing the Notebook itself.
If you Run all code in the Notebook before Publishing, using the 'Run' button in the top right of the Source Pane, RStudio can then find the objects you want to embed.
Alternatively, you can click the green play (right arrow) in the top right of each code chunk in the Notebook to run each code chunk.
Run the code chunk using CTRL+SHIFT+Enter. If you now Preview the R Notebook, the code output will be available. The code must be executed in the editor before it gets reflected in the Preview.
Related
I have successfully used save_kable() from kableExtra to export latex tables into *.png before. However, after updating R to the version 4.0.2, save_kable always ends with R fatal error (no specific error message is shown, the session is just aborted). I installed a clean version o R 3.6.3 and everything works fine again.
Next, I re-installed MikTEX, but this does not seem to be the problem because R Markdown can knit a .pdf file without an issue (in the 4.0.2 version). Also, using save_kable with "html" options works fine and exports the table into .png. The problem seems to be specific for latex.
Looking at sessionInfo(), the only difference is that R 3.6.3 automatically loads the 'magick' package, while R 4.0.2 does not. However, loading the magick package manually in the latter R version does not solve the problem. Then, of course, the sessions differ in the "compiler" package versions. Maybe this is the source of the problem?
Any help would be much appreciated. The problem can be reproduced with minimal code such as
kable(mtcars, "latex") %>% save_kable("test.png")
Here is the sessionInfo
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
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] magick_2.4.0 kableExtra_1.1.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.11 knitr_1.29 xml2_1.3.2 magrittr_1.5
[6] hms_0.5.3 rvest_0.3.5 munsell_0.5.0 viridisLite_0.3.0 colorspace_1.4-1
[11] R6_2.4.1 rlang_0.4.7 stringr_1.4.0 httr_1.4.1 tools_4.0.2
[16] webshot_0.5.2 xfun_0.15 htmltools_0.5.0 ellipsis_0.3.1 digest_0.6.25
[21] tibble_3.0.3 lifecycle_0.2.0 crayon_1.3.4 readr_1.3.1 vctrs_0.3.2
[26] glue_1.4.1 evaluate_0.14 rmarkdown_2.3 stringi_1.4.6 compiler_4.0.2
[31] pillar_1.4.6 scales_1.1.1 pkgconfig_2.0.3
This seems to be a windows specific problem. I actually just asked a recent question here
kableExtra HTML styling in Rmarkdown and kable_save()
Some of the things I have seen mentioned as potential fixes are listed there such as updating ghostscript, not using tinytext, updating some latex packages including 'standalone', and editing the policy.xls document in ImageMagick ImageMagick security policy 'PDF' blocking conversion.
None of these worked for me and I get the same crashing issues the second I try to kable_save a latex format into png. However, some other Windows users have found success with the steps above so maybe try that out and see how it goes.
I installed the shiny package, but after running the example file: runExample("01_hello"), the pop up does not show the expected interface (for example, there's no sliding bar, and nothing happens after entering manually a number of bins). I see the same effect if I view it in an external browser as well. See the below picture for better understanding. I tried similar cases and it is always the same...
library(shiny)
runExample("01_hello")
The app that opens looks like this:
But should look like this:
I just installed the latest version of R and RStudio for Windows10 (64bit) but still have the issue... Also tried to update the graphic drivers in case the problem was with them, but no solution so far. Any hints?
Here the session info.
R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.8.0.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 crayon_1.3.4 assertthat_0.2.1 R6_2.4.0
[5] magrittr_1.5 pillar_1.3.1 rlang_0.3.4 rstudioapi_0.10
[9] tools_3.5.3 glue_1.3.1 purrr_0.3.2 xfun_0.6
[13] compiler_3.5.3 pkgconfig_2.0.2 knitr_1.22 tidyselect_0.2.5
[17] tibble_2.1.1
Finally I think I got an answer. My R library was saved under a path that was not compatible with shiny (meaning that the path had special signs like à). I solved the problem deleting the libraries and reinstalling them in a new path C:/Program Files/R/R-3.5.3/library. For that may be needed to run R-Studio as admin.
Thanks for the help, was much appreciated :)
I am trying to knit a flexdashboard to an html file. My flexdashboard includes leaflet maps. The knit.md file compiles correctly. At the last stage, converting the knit.md to an html file, I get an error. Apparently leaflet is looking for html dependencies in the R 3.3.2 folder, rather than the R 3.4.2 folder. I originally built this flexdashboard months ago on a different machine on which I had R 3.3.2 (although I was using 3.4.1 I believe to build this). So the problem appears to be that leaflet still looks in the old R-3.3.2 folder for its dependencies even though I've updated and reinstalled leaflet multiple times, trying to fix this problem.
Does anyone know how to tell leaflet to look in the correct place for its html dependencies?
output file: myflexdashboard.knit.md
Error: path for html_dependency not found: C:/R/R-3.3.2/library/leaflet/htmlwidgets/lib/leaflet-providers
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.2 backports_1.1.1 magrittr_1.5 rprojroot_1.2 htmltools_0.3.6
[6] tools_3.4.2 flexdashboard_0.5.1 yaml_2.1.15 Rcpp_0.12.14 stringi_1.1.6
[11] rmarkdown_1.8 knitr_1.17 jsonlite_1.5 stringr_1.2.0 digest_0.6.12
[16] packrat_0.4.8-1 evaluate_0.10.1
When I knit to HTML, images show up fine in the .html file, but not the .nb.html one. MWE is the R Notebook template: the plot(cars) image does not show.
Per suggestions listed here: RStudio notebook does not show data.frames when I compile, I tried older/newer/dev versions of rmarkdown. I also tried newer/dev versions of knitr. Nothing helped. I have RStudio version 1.0.136.
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X Yosemite 10.10.5
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_1.12.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.8 withr_1.0.2 digest_0.6.11 rprojroot_1.2 R6_2.2.0
[6] jsonlite_1.2 backports_1.0.5 git2r_0.15.0 magrittr_1.5 evaluate_0.10
[11] highr_0.6 httr_1.2.1 stringi_1.1.2 curl_2.3 rstudioapi_0.6
[16] rmarkdown_1.3 tools_3.3.2 stringr_1.1.0 yaml_2.1.14 rsconnect_0.7
[21] base64enc_0.1-3 memoise_1.0.0 htmltools_0.3.5 knitr_1.15.8
Thanks to RStudio for pointing out that this is expected behavior. I had switched the chunk output setting to Chunk Output in Console so I could view plots in the plot window. I didn't realize that all chunks must be run inline to appear in the notebook. I switched back to Chunk Output Inline, ran the chunks, and all was well.
I am reading in some excel data into R in a loop because I have a bunch of files. This is something that I do regularly. I am having some trouble though and I'm not sure even how to make reproducible example. So i have all the files that I want in one directory and I am reading them in using this set of commands:
## Because I want warnings to stop the loop at a certain file so I can diagnose
options(warn=2)
xl_load_in <- c()
for (x in list.files(pattern="*\\.xls")) {
cat(x, "\n ")
u <- read_excel(x,col_types=c("text","text","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","text"))
xl_load_in <- tbl_df(rbind(xl_load_in, u))
}
options(warn=0)
So this is both a tool to read in files but also, using the warn toggle, I can diagnose which files aren't reading in correctly.
Now the problem: From a fresh reboot and I can rename and save the excel files in the directory. If, however, I run the above R code, I lose the permission to save or rename the excel file where the loop broke (There are small issues with the excel files that have to rectified manually). For example if I try to rename the file upon which the loop broke I get this windows error:
The action can't be completed because the file is open in RStudio R
Session.
If I reboot, I can again modify the file in question. But before the reboot I can't save or rename the file. Can anyone explain this behaviour where R or Rstudio seems to be taking over my permissions?
Update If I close RStudio, the permissions are returned. If I do the same sequence of commands above using RGUI for Windows, the problem in replicated indicating the issue is not an RStudio problem.
sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] stringr_1.1.0 readxl_0.1.1 lubridate_1.6.0 dplyr_0.5.0 purrr_0.2.2 readr_1.0.0 tidyr_0.6.0 tibble_1.2
[9] ggplot2_2.2.0 tidyverse_1.0.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 assertthat_0.1 R6_2.2.0 grid_3.3.2 plyr_1.8.4 DBI_0.5-1 gtable_0.2.0
[8] magrittr_1.5 scales_0.4.1 stringi_1.1.2 lazyeval_0.2.0 tools_3.3.2 munsell_0.4.3 colorspace_1.3-0