-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.R
More file actions
49 lines (42 loc) · 1.51 KB
/
run.R
File metadata and controls
49 lines (42 loc) · 1.51 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## 07/08/2014
## D.J. Bennett
## Run all analyses
## Timestamp
cat (paste0 ('\nrun.R started at [', Sys.time (), ']'))
## Library
library (plyr)
## Load parameters
parfile <- 'hydra.R'
source (file.path ('parameters', parfile))
# if there isn't a results folder, create one
if (!file.exists ('results')) {
dir.create ('results')
}
# make sure analysis results folder doesn't already exist
for (analysis.name in names (analysis.parameters)) {
if (file.exists (file.path ('results', analysis.name))) {
stop (paste0 ('[', analysis.name, '] already exists in results folder'))
}
}
## Iteration function
iterateAnalyses <- function (i) {
# analysis parameters
name <- names (analysis.parameters)[i]
pars <- analysis.parameters[[i]]
cat ('######################################\n')
cat (paste0 ('\n Analysis [', name, '], [', i, '/', length (analysis.parameters),']'))
cat ('######################################\n\n')
cat ('\n--------------------------------')
cat (' Model stage ....\n')
cat ('\n--------------------------------\n')
source (file.path ('stages', 'model.R'), print.eval = TRUE, local = TRUE)
cat ('\n--------------------------------')
cat (' Calculate stage ....\n')
cat ('\n--------------------------------\n')
source (file.path ('stages','calculate.R'), print.eval = TRUE, local = TRUE)
}
## Run
m_ply (.data = data.frame (i = 1:length (analysis.parameters)),
.fun = iterateAnalyses)
## Timestamp
cat (paste0 ('\nrun.R finished at [', Sys.time (), ']'))