Skip to content

Instantly share code, notes, and snippets.

@darokun
Created April 17, 2018 01:29
Show Gist options
  • Save darokun/827f21dcfed92ef04550f1aa7eb84414 to your computer and use it in GitHub Desktop.
Save darokun/827f21dcfed92ef04550f1aa7eb84414 to your computer and use it in GitHub Desktop.
# Based on this blog post: https://www.r-bloggers.com/updating-r/
### 1
## Change accordingly
list_dir <- "/Library/Frameworks/R.framework/Resources/library"
## Get the list of installed packages
installed <- dir(.libPaths())
## Save the list for later use
save(installed, file = file.path(list_dir, paste0(Sys.Date(), '-installed.Rdata')))
## Explore the list
head(installed)
length(installed)
### 2
## Change accordingly
list_dir <- "/Library/Frameworks/R.framework/Resources/library"
## Find the corresponding Rdata files
previous <- dir(path = list_dir, pattern = 'installed.Rdata')
## Load the latest one
load(file.path(list_dir, previous[length(previous)]))
## Just checking it
head(installed)
current <- dir(.libPaths())
## For Bioconductor and CRAN packages
source('http://bioconductor.org/biocLite.R')
biocLite(installed[!installed %in% current])
## Check which packages are missing
current_post_installation <- dir(.libPaths())
installed[!installed %in% current_post_installation]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment