generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_outcome_output.R
48 lines (32 loc) · 1.27 KB
/
make_outcome_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
# 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 <- "cohortoverlap"
outcomes <- "depression;anxiety_general"
} else {
output <- args[[1]]
outcomes <- args[[2]]
}
# Separate outcomes -------------------------------------------------------------
print('Separate outcomes')
outcomes <- stringr::str_split(as.vector(outcomes), ";")[[1]]
# Create blank table -----------------------------------------------------------
print('Create blank table')
df <- NULL
# Add output from each cohort --------------------------------------------------
print('Add output from each cohort')
for (i in outcomes) {
tmp <- readr::read_csv(paste0("output/",output,"_",i,"_midpoint6.csv"))
df <- rbind(df, tmp)
}
# Save output ------------------------------------------------------------------
print('Save output')
readr::write_csv(df, paste0("output/",output,"_output_midpoint6.csv"))