R update packages

By: | Comments: No Comments

Posted in categories: Uncategorized

install.packages(
lib = lib <- .libPaths()[1],
pkgs = as.data.frame(installed.packages(lib), stringsAsFactors=FALSE)$Package,
type = ‘source’
)

 

# store_packages.R
#
# stores a list of your currently installed packages

tmp = installed.packages()

installedpackages = as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpackages, file="~/Desktop/installed_packages.rda")


# restore_packages.R
#
# installs each package from the stored list of packages

load("~/Desktop/installed_packages.rda")

for (count in 1:length(installedpackages)) install.packages(installedpackages[count])

Be the first to comment!

Leave a Reply