Created
October 12, 2016 18:05
-
-
Save pachadotdev/a761a35602a2386024e304c5d034c4b9 to your computer and use it in GitHub Desktop.
Automatically downloads and/or load the libraries for your Rmds/R scripts
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tired of R code not working on the fly even between your own computers? Think in a reproducible way.