Search code examples
rtestingr-markdownworkflow

R Markdown workflow/testing


I often create fairly large dashboards with R Markdown. Every time I create a new output (e.g., a new chunk containing an additional table or chart), I want to check for any display issues. My current workflow for doing this is slow for two reasons:

  1. I want to test in the browser, but there doesn't seem to be an option to knit a document directly to the browser, so I have to knit to the default window and then click "Open in Browser" (see also here When knitting RMarkdown to HTML with RStudio, is it possible to view directly in browser, instead than previewing in a window?);
  2. I do not know of a way to only knit a subset of chunks. For example, is there a way to knit in "test" mode, whereby only certain marked chunks are knitted?

Thanks for any advice.


Solution

  • To answer your workflow questions

    1. rmarkdown::run("filename.Rmd", shiny_args = list(launch.browser = TRUE))

    is what you can use, which uses a shiny argument, which will render your Rmarkdown file and send it directly to the browser when ran. answer found here

    1. in your chunks, you want the eval=FALSE/eval=TRUE which tells R to evaluate the chunk or not. You can also use echo=FALSE to hide code in the chunk from displaying. Rstudio has added a GUI option to easily select these options with a click of a mouse

    enter image description here

    Where only the selected chunk I chose to knit, was actually knitted(1 plot instead of 2.

    enter image description here