Skip to content

Instantly share code, notes, and snippets.

@benmarwick
Last active February 21, 2021 01:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save benmarwick/5054846 to your computer and use it in GitHub Desktop.
Save benmarwick/5054846 to your computer and use it in GitHub Desktop.
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
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)
@Howquez
Copy link

Howquez commented Feb 19, 2020

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