5

I have a project that used R 3.6, I have upgraded R to 4.0.2 and would like to use 4.0.2 for this project. I'm wondering how to go about doing so, or should I completely delete renv/ and rebuild?

Edit

I have done the following:

> renv::init()
This project already has a lockfile. What would you like to do?

1: Restore the project from the lockfile.
2: Discard the lockfile and re-initialize the project.
3: Activate the project without snapshotting or installing any packages.
4: Abort project initialization.

And selected 2 from the above, this seems to be reasonable.

baxx
  • 3,956
  • 6
  • 37
  • 75

1 Answers1

2

Different versions of R will get their own independent project libraries, so technically speaking you can use different versions of R with the same renv project.

That said, each project only has a single lockfile -- to update the lockfile, you can either call renv::snapshot() to create a brand new lockfile, or re-initialize the project with renv::init() (as you've done) -- both are correct.

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88
  • Thanks, I'm not sure that I fully understand what you mean in the first paragraph. Different R versions (on system) will have different project libraries (so dplyr for 3.6.2 will be different to dplyr for 4.0.2 I presume). If you have any documentation for this it'd be good for me to be able to skim, thanks – baxx Sep 06 '20 at 19:30
  • 1
    so if there is only one lock file, and only one R version is recorded in the lock file, wouldn't there be package clashes between different versions of R? – leo Mar 03 '21 at 17:44
  • 1
    Yes. The intention (in general) is that a particular project should be tied to a single version of R. If you want to associate a project with multiple versions of R / multiple libraries / multiple libraries, then you might want to use the profiles feature in renv 0.13.0: https://rstudio.github.io/renv/articles/profiles.html – Kevin Ushey Mar 03 '21 at 20:12