-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.R
More file actions
30 lines (24 loc) · 680 Bytes
/
update.R
File metadata and controls
30 lines (24 loc) · 680 Bytes
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
27
28
29
30
args = commandArgs(trailingOnly=TRUE)
"required"<-
function(dependency)
{
nz_repo <- 'http://cran.stat.auckland.ac.nz'
userdir <- unlist(strsplit(Sys.getenv("R_LIBS_USER"),.Platform$path.sep))[1L]
if (!file.exists(userdir)) {
if (!dir.create(userdir, recursive = TRUE)) {
stop("Unable to create ", sQuote(userdir))
}
}
# install package
update.packages(dependency, lib=userdir, repos=nz_repo, dependencies = TRUE)
library(dependency, lib.loc=userdir, character.only = TRUE)
}
if(length(args)==0){
for(pkg in rownames(installed.packages())){
required(as.character(pkg))
}
} else {
for(pkg in args){
required(as.character(pkg))
}
}