Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rscript to use renv environment

Tags:

How do I execute a command using RScript myfile.R so that it uses the renv environment of the project/directory it's in, NOT my default environment?

like image 643
dvanic Avatar asked Feb 22 '21 06:02

dvanic


1 Answers

There are a couple ways:

  1. Ensure your working directory is set to the root of your renv project, and that the renv project's auto-loader is active. (You can set up the auto-loader by calling renv::activate() from R in that project.)

  2. In your script, explicitly call renv::load("/path/to/project") to load the requested project.

If neither of these methods suffice, please file an issue at https://github.com/rstudio/renv/issues.

like image 105
Kevin Ushey Avatar answered Oct 13 '22 10:10

Kevin Ushey