How to update the version of R used within a project, using renv

2.7k Views Asked by At

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.

1

There are 1 best solutions below

3
On BEST ANSWER

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.