generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_other_output.R
49 lines (33 loc) · 1.28 KB
/
make_other_output.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
41
42
43
44
45
46
47
48
49
# Load packages ----------------------------------------------------------------
print('Load packages')
library(magrittr)
library(data.table)
# Source functions -------------------------------------------------------------
print('Source functions')
source("analysis/fn-check_vitals.R")
# Specify arguments ------------------------------------------------------------
print('Specify arguments')
args <- commandArgs(trailingOnly=TRUE)
if(length(args)==0){
output <- "table1"
cohorts <- "prevax_extf;vax;unvax_extf"
} else {
output <- args[[1]]
cohorts <- args[[2]]
}
# Separate cohorts -------------------------------------------------------------
print('Separate cohorts')
cohorts <- stringr::str_split(as.vector(cohorts), ";")[[1]]
# Create blank table -----------------------------------------------------------
print('Create blank table')
df <- NULL
# Add output from each cohort --------------------------------------------------
print('Add output from each cohort')
for (i in cohorts) {
tmp <- readr::read_csv(paste0("output/",output,"_",i,"_midpoint6.csv"))
tmp$cohort <- i
df <- rbind(df, tmp)
}
# Save output ------------------------------------------------------------------
print('Save output')
readr::write_csv(df, paste0("output/",output,"_output_midpoint6.csv"))