Search code examples
rrstudioknitrr-markdownrnotebook

Images not showing in R notenook (nb.html file)


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   

Solution

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