Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Automatically downloads and/or load the libraries for your Rmds/R scripts
download_and_or_load <- function(x){
y <- x[!(x %in% installed.packages()[, "Package"])]
if (length(y))
install.packages(y, dependencies = TRUE)
sapply(x, require, character.only = TRUE)
}
my_libraries <- c("ggplot2", "dplyr", "purrr")
download_and_or_load(my_libraries)
@pachamaltese

This comment has been minimized.

Copy link
Owner Author

pachamaltese commented Oct 12, 2016

Tired of R code not working on the fly even between your own computers? Think in a reproducible way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.