How can renv::use() create a truly standalone Rmd file if renv is required to be installed to knitr the file?

renv::use() is described as "a useful way of sharing standalone R scripts", specifically Rmd and Qmd documents. However, the presence of renv:: suggests that the scripts will not knitr or render unless renv is already installed, is that correct? If so, how can this be done in a standalone way, without requiring other files to bootstrap the installation of renv?

EDIT: For now I've added

if(!("renv" %in% installed.packages())) install.packages("renv", repos= "https://cloud.r-project.org")

This seems to work.

That's correct. While you still need renv in order to render the document, it helps take care of installing specific versions of package dependencies before running a script or R Markdown document.

That is, the document is not "standalone" per-se, but you can feel more confident that the document, when executed, will use a fixed set of package dependencies as declared in the renv::use() invocation.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.