Suppose I have R version 3.x.x installed, and I upgrade to version 4.x.x, is there any quick/easy way to install all the new versions of the libraries I had installed?
Please assume all the packages are on CRAN
Suppose I have R version 3.x.x installed, and I upgrade to version 4.x.x, is there any quick/easy way to install all the new versions of the libraries I had installed?
Please assume all the packages are on CRAN
Don't know if this is quick and easy, but I think the pacman
package can be useful.
pacman::p_lib()
to return a vector of your installed packages, and save them onto disk use saveRDS()
.For instance,
mypks <- pacman::p_lib()
saveRDS(mypks, "~/mypks.rds")
Update R.
Import the vector from step 1 using readRDS()
and run install.packages()
with the object.
For instance,
mypks <- readRDS("~/mypks.rds")
install.packages(mypks)
Run this in the previous R installation:
# install.packages("pacman")
library(pacman)
dput(pacman::p_lib())
Copy the output to clipboard.
Open your new R version, paste the output from the previous step in place of ***paste output here***
:
vector_of_packages <- ***paste output here***
install.packages(vector_of_packages)
Notes:
The latest versions of RStudio have an Update option next to the list of packages installed under the Packages tab.