Created
August 11, 2018 11:30
-
-
Save chrisvoncsefalvay/08b3dcb424d8f5ebae7f5cbaf9b5d2ac to your computer and use it in GitHub Desktop.
Install if not present
This file contains hidden or 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
# R code that checks if a package is installed, and installs it from CRAN if not. | |
#' Install packages from a list if not present | |
#' | |
#' Installs packages from a provided list if they are not already installed. | |
#' | |
#' @param packages_list a list of packages to be installed | |
#' | |
#' @export | |
cran_install_if_not_present <- function(packages_list) { | |
tbi <- packages_list[!(packages_list %in% installed.packages()[,"Package"])] | |
if(length(tbi)) { | |
install.packages(tbi) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment