Is there a way to knitr markdown straight out of your workspace using RStudio?

前端 未结 4 481
暖寄归人
暖寄归人 2020-12-13 20:13

I wonder whether I can use knitr markdown to just create a report on the fly with objects stemming from my current workspace. Reproducibility is not the issue h

相关标签:
4条回答
  • 2020-12-13 20:21

    Might be easier to save you data from your other session using:

    save.image("C:/Users/Desktop/example_candelete.RData")
    

    and then load it into your MD file:

    load("C:/Users/Desktop/example_candelete.RData")
    
    0 讨论(0)
  • 2020-12-13 20:22

    The Markdownreports package is exactly designed for parsing a markdown document on the fly.

    0 讨论(0)
  • 2020-12-13 20:36

    As Julien Colomb commented, I've found the best thing to do in this situation is to save the large objects and then load them explicitly while I'm tailoring the markdown. This is a must if your data is coming through an ODBC and you don't want to run the entire queries repeatedly as you tinker with fonts and themes.

    0 讨论(0)
  • 2020-12-13 20:42

    RStudio opens a new R session to knit() your R Markdown file, so the objects in your current working space will not be available to that session (they are two separate sessions). Two solutions:

    1. file a feature request to RStudio, asking them to support knitting in the current R session instead of forcibly starting a new session;
    2. knit manually by yourself: library(knitr); knit('your_file.Rmd') (or knit2html() if you want HTML output in one step, or rmarkdown::render() if you are using R Markdown v2)
    0 讨论(0)
提交回复
热议问题