Last active
August 29, 2015 14:06
-
-
Save gyli/75f6443614e653cdcbcb to your computer and use it in GitHub Desktop.
Package loading in R (Check if installed before loading)
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
pkg.install <- function(x) | |
{ | |
if (!require(x,character.only = TRUE)) | |
{ | |
install.packages(x,dep=TRUE) | |
if(!require(x,character.only = TRUE)) stop("Package not found") | |
} | |
} | |
pkg.install("DBI") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment