Created
October 20, 2015 14:55
-
-
Save mrecos/889e301c7ce4a3c4f960 to your computer and use it in GitHub Desktop.
R Package Loader
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
load.fun <- function(x) { | |
x <- as.character(x) | |
if(isTRUE(x %in% .packages(all.available=TRUE))) { | |
eval(parse(text=paste("require(", x, ")", sep=""))) | |
print(paste(c(x, " : already installed; requiring"), collapse='')) | |
} else { | |
if(x == "twitteR"){ | |
print(paste(c(x, " : not installed; installing"), collapse='')) | |
install_github("twitteR", username="geoffjentry") | |
print(paste(c(x, " : installed and requiring"), collapse='')) | |
eval(parse(text=paste("require(", x, ")", sep=""))) | |
} else { | |
#update.packages() | |
print(paste(c(x, " : not installed; installing"), collapse='')) | |
eval(parse(text=paste("install.packages('", x, "')", sep=""))) | |
print(paste(c(x, " : installed and requiring"), collapse='')) | |
eval(parse(text=paste("require(", x, ")", sep=""))) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment