R works by defaultly by installing packages to a central library and shares them between the projects. It sounds like a good and time-saving feature. After all, you don’t need to install the same package in every project. But that’s where the problems arise. You might have a newer version of some package than your coworkers – resulting in a deprecated or not-implemented functionality.
Install renv
pacman::p_load(renv)
renv create separate, reproducible environment that you and your coworkers can use, hassle free
This nice post introduced how to use it to manage dependencies in R projects easily
Remove renv
- Deactivate
renvin a project
renv::deactivate()- Remove auto loader
.Rprofile, but doesn’t touch any otherrenvfiles used in the project. - To completely remove
renvfrom a project, delete the project’srenvfolder andrenv.locklockfile as desired. - If you want to completely remove any installed renv infrastructure components from your entire system
root <- renv::paths$root()
unlink(root, recursive = TRUE)
### Remove packages
utils::remove.packages("renv")