Tend to be quite minimalist in my use of R packages where possible, often only using data.table and ggplot2, so I don’t worry much about breaking changes. But sometimes you have to use unstable R packages (version number < 1.0.0). I wish there was a way to “pin” the version of a single package without causing problems with the installation of other packages, but instead the best way currently seems to be to use the renv package and “pin” the versions of all the packages you are using for a particular project. I had to use it last week and am recording what worked for me (for posterity).
- Create an RStudio project and initialise Git.
- Run
renv::init(). - Install packages using
install.packages,remotes::install_gitand/orremotes::install_github. - Run
renv::snapshot(). - Commit the following:
.Rprofile,.gitignore,renv.lockand.Rprojfiles; alsorenv/folder
After cloning the project, another user can then run renv::restore() to get the same package versions.
More info: