transfer from old repo
This commit is contained in:
parent
cfa4a5f9cc
commit
277e2b8cf3
1111 changed files with 83736 additions and 0 deletions
50
1 PA Decline/data_format.R
Normal file
50
1 PA Decline/data_format.R
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
## Article 1 outcome group definition script
|
||||
## To be enriched from Statistics Denmark
|
||||
##
|
||||
## Based on the ItMLiHSmar2022 course
|
||||
|
||||
library(Hmisc)
|
||||
library(dplyr)
|
||||
# library(daDoctoR)
|
||||
library(tidyselect)
|
||||
|
||||
# Setting final primary output from "pout"
|
||||
if (pout=="drop"){
|
||||
X_tbl <- X_tbl|>
|
||||
mutate(group=pase_drop_fac)
|
||||
|
||||
# print(quantile(as.numeric(X_tbl$pase_0)))
|
||||
# print(quantile(as.numeric(X_tbl$pase_6)))
|
||||
# print(summary(X_tbl$pase_0_cut))
|
||||
|
||||
X_tbl_f <- X_tbl|>
|
||||
filter(pase_0_cut!=1)|>
|
||||
select(-starts_with("pase_"))
|
||||
}
|
||||
|
||||
if (pout=="hop"){
|
||||
X_tbl <- X_tbl|>
|
||||
mutate(group=pase_hop_fac)
|
||||
|
||||
# print(quantile(as.numeric(X_tbl$pase_0)))
|
||||
# print(quantile(as.numeric(X_tbl$pase_6)))
|
||||
# print(summary(X_tbl$pase_0_cut))
|
||||
|
||||
X_tbl_f <- X_tbl|>
|
||||
filter(pase_6_cut!=1)|>
|
||||
select(-starts_with("pase_"))
|
||||
}
|
||||
|
||||
# Dropping non-complete for analysis
|
||||
Xy <- X_tbl_f|>
|
||||
na.omit()|> # Keeping only complete observations
|
||||
select(-c(tci) # Left out of model as no present in drop-group
|
||||
)|>
|
||||
mutate(mrs_0=factor(ifelse(mrs_0==1,1,2))) # Sets binary mRS 0 to include in glmnet, 0 or above
|
||||
|
||||
label(Xy) = as.list(var.labels[match(names(Xy), names(var.labels))])
|
||||
|
||||
X<-dplyr::select(Xy,-c(group, -starts_with("pase_")) # Exclude primary outcome
|
||||
)
|
||||
y<-Xy$group
|
||||
|
||||
Loading…
Reference in a new issue