A method to automatically download, install and load R packages that only requires the package name to be typed once. Credits: http://stackoverflow.com/a/8176099/1036500 & http://stackoverflow.com/a/4090208/1036500
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list.of.packages <- c("xx", "yy") # replace xx and yy with package names | |
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])] | |
if(length(new.packages)) install.packages(new.packages) | |
lapply(list.of.packages, require, character.only=T) |
Salut,
do you have suggestions on how to (elegantly) include githubinstall() or install_github() to this?
Thanks in advance
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Ben,
This is great. I would only make a couple adjustments to the third and fourth line.
Otherwise this will only load packages that aren't installed. Whereas the goal is to load all packages, installed or not.