-
Notifications
You must be signed in to change notification settings - Fork 5
/
installPackages.R
26 lines (22 loc) · 1.02 KB
/
installPackages.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
###########################################################
# INSTALL PACKAGES
#Rscript installPackages.R packages=RCurl,snow,ptw,bitops,mapdata,XML,rgeos,rgdal,MODIS,scidb verbose=0 quiet=0
###########################################################
repositories <- c("http://cran.rstudio.com",
"http://R-Forge.R-project.org")
#Get arguments
argsep <- "="
keys <- vector(mode = "character", length = 0)
values <- vector(mode = "character", length = 0)
for (arg in commandArgs()){
if(agrep(argsep, arg) == TRUE){
pair <- unlist(strsplit(arg, argsep))
keys <- append(keys, pair[1], after = length(pair))
values <- append(values, pair[2], after = length(pair))
}
}
packages <- unlist(strsplit(values[which(keys == "packages")], ","))
#repositories <- unlist(strsplit(values[which(keys == "repositories")], ","))
verbose <- as.numeric(values[which(keys == "verbose")])
quiet <- as.numeric(values[which(keys == "quiet")])
install.packages(pkgs = packages, repos = repositories, verbose = verbose, quiet = quiet)