forked from hobbes8080/risc-19-icu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
R_MANAGE_DATAMANAGEMENTWORKFLOW.R
46 lines (38 loc) · 1.51 KB
/
R_MANAGE_DATAMANAGEMENTWORKFLOW.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
## Data management workflow
## 2020-03 by M. Hilty
paste(R.Version()$version.string, R.Version()$nickname)
## simplified initialization procedure
## install / load packages
source("R_MANAGE_PACKAGES.R")
## define custom functions
source("R_FUNCTION_SOFA.R")
## Import raw Data
source("R_MANAGE_IMPORT.R")
## TRANSFORM
## get column ranges (procedure is agnostic to database version)
cl <- colnames(data)
col_adm <- which(cl %in% "local_nr")+1
col_icu <- which(cl %in% "patient_characteristics_complete")+1
col_dis <- which(cl %in% "icu_parameters_complete")+1
col_admin <- which(cl %in% "outcome_complete")+1
## transform and calculate derived variables
source("R_MANAGE_TRANSFORM.R")
## calculate summary
## --------------------------------
casenum <- nrow(patients_char)
centers <- unique(data$center_ID)
centers_incl <- length(centers)
snapdate <- snapshot_date
snapstr <- snapshot_date_str
## ------------------
## data available at this point:
## data (raw export data from RedCAP, with automatic selection of the latest file)
## casenum (number of included patients)
## centers (list of centers that have included patients)
## centers_incl (number of centers that have included patients)
## snapshot_date (date / time of snapshot from RedCAP DB, automatically detected)
## snapshot_date_str (timestamp to be used for output filenames)
## patients_char (patient characteristics and outcome)
## patients_icu (icu treatment data, long dataframe mit $time {0, 1, 2, 3, 5, 7})
## ------------------
## input data is located in ./Input-data