Closed connorp closed 4 years ago
Without looking specifically at your problem, I suggest you have a look at my reproducible template that uses RMarkdown. It basically uses a workaround that temporarily writes the library(xyz)
calls into a file and then checkpoint
reads from that file to load/install the packages. See this part of the code.
That is relevant to the problem, but this issue nevertheless seems like something that should be addressed. A workaround is not a fix.
Absolutely agree!
For this to work correctly, run rmarkdown::render("yourfile.Rmd")
in the REPL.
Also note that fundamentally, checkpoint uses directories to define projects. This is problematic with Rmd files as:
So, best practice would be to put your Rmds in a directory of their own, and call rmarkdown::render
with the knit_root_dir
argument set appropriately.
I am hoping to use
scanForPackages()
to identify all packages used to generate an RMarkdown document, within the document. When run in the console,scanForPackages(use.knitr = TRUE)
is able to detect all the packages loaded in the.Rmd
file. But when knitted, it returns without any packages.Minimal example, saved as
test.Rmd
:$pkgs [1] "checkpoint" "pander"
$error character(0)
No file at path '/var/folders/6q/wp5m99kx41z7txrfxwywf2wr0000gn/T//RtmpbZ4NGz/file32a67e5f45d9.Rmd'.
$pkgs
character(0)
$error
[1] "test.Rmd"