Code works interactively but not while knitting

后端 未结 1 2055
忘了有多久
忘了有多久 2020-12-20 03:24

I have an RMarkdown document with some R code in it. The code works fine when I\'m running it interactively in the console. However, when I try to knit the document (using t

相关标签:
1条回答
  • 2020-12-20 04:18

    When you compile a document (using the "knit" button in RStudio), knitting takes place in a separate R session. Therefore, your document must be self-contained:

    1. Objects from the Global Environment of your interactive sessions are not available when knitting. You must create/load all objects from within your document.
    2. You must load all packages used from within your document.

    Also note that while knitting, your working directory is changed to the directory containing your document (by default). Therefore, relative paths (for example, paths to data sets you want to read) might not point to the expected files.

    0 讨论(0)
提交回复
热议问题