forestgeo / learn

Links to interesting articles, videos, tutorials, tips, and more
5 stars 8 forks source link

Update R to a minor version #209

Open maurolepore opened 5 years ago

maurolepore commented 5 years ago

Adapted from https://whattheyforgot.org/maintaining-r.html

# Create a new directory for the version of R (on mac: ~/Library/R/major.minor/library)
new_version_major_minor <- "3.6"
path <- fs::path("~/Documents/R/win-library", new_version_major_minor)
fs::dir_create(path)

# Re-start R so the .libPaths are updated

# Install new version of R
installr::updater()

install.packages("fs")

# Lookup what packages were in your old package library
old_version_major_minor <- "3.5"
old_path <- fs::path("~/Documents/R/win-library", old_version_major_minor)
pkgs <- fs::path_file(fs::dir_ls(old_path))

# Filter these packages as needed
pkgs_filetered <- grep("^_cache", pkgs, value = TRUE, invert = TRUE)

# Install the packages in the new version
install.packages(pkgs_filetered)