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?
There are a couple ways:
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.)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With