Reputation: 359
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:
Upvotes: 0
Views: 2298
Reputation: 1712
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.
Upvotes: 0
Reputation: 464
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.
Upvotes: 1