Skip to content

Instantly share code, notes, and snippets.

@jcjaimes
Forked from arne-cl/restore_packages.R
Created January 10, 2018 14:45
Show Gist options
  • Select an option

  • Save jcjaimes/1f346f1b9e398f01e7366d0c71c37d05 to your computer and use it in GitHub Desktop.

Select an option

Save jcjaimes/1f346f1b9e398f01e7366d0c71c37d05 to your computer and use it in GitHub Desktop.
save/load/install a list of your currently installed R packages
# restore_packages.R
#
# installs each package from the stored list of packages
# source: http://hlplab.wordpress.com/2012/06/01/transferring-installed-packages-between-different-installations-of-r/
load("~/installed_packages.rda")
for (count in 1:length(installedpackages)) {
install.packages(installedpackages[count])
}
# store_packages.R
#
# stores a list of your currently installed packages
# source: http://hlplab.wordpress.com/2012/06/01/transferring-installed-packages-between-different-installations-of-r/
tmp = installed.packages()
installedpackages = as.vector(tmp[is.na(tmp[,"Priority"]), 1])
save(installedpackages, file="~/installed_packages.rda")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment