lvalnegri

r_packages.R

Apr 8th, 2019
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.08 KB | None | 0 0
  1. # remember to first cd into the subfolder containing the list of packages to install (~/scripts/r_packages/)
  2.  
  3. # if you're in need to uninstall all (non *core*) libraries
  4. # y <- as.data.frame(installed.packages())
  5. # y <- as.character(unique(y[is.na(y$Priority), 'Package']))
  6. # remove.packages(y)
  7.  
  8. # install packages from Bioconductor which are dependencies for subsequent CRAN packages
  9. if(!require('BiocManager')) {
  10.     install.packages('BiocManager')
  11.     BiocManager::install('graph')
  12.     BiocManager::install('S4Vectors')
  13. }
  14.  
  15. # install CRAN packages not currently installed
  16. pkgs <- readLines(file('r_packages.lst'))
  17. pkgs.not <- pkgs[!sapply(pkgs, require, char = TRUE)]
  18. if(length(pkgs.not) > 0) install.packages(pkgs.not)
  19. lapply(pkgs, require, char = TRUE)
  20.  
  21. # summary
  22. y <- data.frame(installed.packages())
  23. message('Number of packages requested: ', length(pkgs))
  24. message('Number of NEW packages installed: ', length(pkgs.not))
  25. message('Number of packages installed: ', nrow(y[is.na(y$Priority),]))
  26. message('Number of dependencies installed: ', nrow(y[is.na(y$Priority),]) - length(pkgs))
Advertisement
Add Comment
Please, Sign In to add comment