-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis_tools.R
40 lines (23 loc) · 1.03 KB
/
analysis_tools.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
library(jsonlite)
read_all_output = function(directory) {
output = read.csv(file.path(directory, "output.csv"))
return(output)
}
# creates a list object of params used in this specific model run.
read_params_used = function(directory) {
#output = fromJSON(read.csv(file.path(directory, "params_used.json")))
output = fromJSON(file.path(directory, "params_used.json"))
return(output)
}
extract_from_repeats = function(root_directory, extractor_func) {
output_list = list()
iRep = 1
while (dir.exists(file.path(root_directory, paste0("rep=", iRep)))) {
rep_directory = file.path(root_directory, paste0("rep=", iRep))
output_list[[iRep]] = extractor_func(rep_directory)
}
return(output_list)
}
rep_outputs = extract_from_repeats(directory, read_params_used) # I don't understand why this function isn't working
directory = "./Model 5.0/model_output/all_random/prop_of_intra_household_interactions=0.5/rep=1"
root_directory = "./Model 5.0/model_output/all_random/prop_of_intra_household_interactions=0.5"