Skip to content

Instantly share code, notes, and snippets.

@sahilseth
Last active July 17, 2017 16:06
Show Gist options
  • Save sahilseth/5dcc71cf2b563edca9b56e2d920543be to your computer and use it in GitHub Desktop.
Save sahilseth/5dcc71cf2b563edca9b56e2d920543be to your computer and use it in GitHub Desktop.
Re-install R packages
#source("https://gist.githubusercontent.com/sahilseth/5dcc71cf2b563edca9b56e2d920543be/raw/re_install_r_pkgs.R")
pkgs = unlist(read.table("~/Dropbox/misc/Rpkgs.txt", stringsAsFactors = FALSE))
# idea1 (works)
ins = installed.packages()[, 1]
need_pkgs = pkgs[which(is.na(match(pkgs, ins)))]
length(need_pkgs)
need_pkgs
source("https://bioconductor.org/biocLite.R")
biocLite("BiocInstaller")
for(pkg in need_pkgs){
# does not re-install uneccesarily
ins = installed.packages()[, 1]
need_pkgs = pkgs[which(is.na(match(pkgs, ins)))]
install.packages(pkg)
# if pkg does not install
if(!pkg %in% installed.packages()[, 1])
BiocInstaller::biocLite(pkg)
}
gh_pkgs = c(#"mikelove/tximport",
"thertrader/fidlr", # fin data loader
"statwonk/openNHTSA",
"hadley/pkgdown",
#"parklab/nozzle",
"dgrtwo/gganimate")
for(pkg in gh_pkgs){
# does not re-install uneccesarily
ins = installed.packages()[, 1]
gh_pkgs = gh_pkgs[which(is.na(match(gh_pkgs, ins)))]
pacman::p_install_gh(pkg)
}
# some packages need linux pkgs installed
# need TTR etc need gfortran, from: https://gcc.gnu.org/wiki/GFortranBinaries#MacOS
# sudo apt-get install libudunits2-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment