0

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).

enter image description here

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:

enter image description here

enter image description here

eflores89
  • 339
  • 2
  • 10
  • 27

2 Answers2

1

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. Notebook and Output before code is run

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.

Notebook and Output after code is run

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.

K.Daisey
  • 464
  • 4
  • 8
  • Hi Daisey, thanks but it does not seem to work. Even evaluating (like the left hand side) I get a blank page on the right. Could it be something about my setup? – eflores89 Jan 10 '17 at 22:47
  • Hi @eflores89 when you evaluate then click Preview, the code does still not post? Could you please post a screen shot of this? What happens when you choose Knit to HTML from the Preview drop down menu? – K.Daisey Jan 11 '17 at 15:02
0

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.

Saurabh Jain
  • 1,600
  • 1
  • 20
  • 30