I'm relatively new to version control/package management but am trying to implement Renv for future projects. Without Renv activated, my system library consists of 521 packages, but when I initialize Renv (0.12.5) in a new project, only 29 packages are shown in the system library. Is this normal, or do I need to change a library path?
In addition, when I install packages, i.e., using install.packages('ggplot2'), each package is downloaded from the repository, even when I previously had it installed in my R library (prior to activating Renv). Does Renv require you to install all packages from repos fresh for each new project?
Lastly, is there a way to update system packages from time to time such that the newer versions are loaded when creating a new project?
Sorry if these are really basic questions - I tried reading the documentation but am still unsure how to resolve these issues.
When you use renv in a project, only the packages you need for this specific project are installed in the renv folder. Thus you would usually expect to have only a subset of packages for each project.
When you install a new package, renv creates a cache of package versions. This means that the first time you install a package using renv, it will fetch a specific version and cache this. The next time you install the same package version, this will be retrieved from the package cache. So in the end you have only a single cached version of each package on your machine.
To update your renv folder, use renv::update().
Also, to install a new package into renv, you can use renv::install(). And a bonus tip: instead of using devtools::install_github("{repo/pkg_name"} you can use renv::install("{repo/pkg_name"}. Thus the same function can be used to install from either CRAN or github.