This commit is contained in:
AG Damsbo 2022-12-06 14:01:31 +01:00
parent 71e67f14a3
commit b32f55a749

View File

@ -44,79 +44,10 @@ source("data_format.R")
## ====================================================================
##
## Baseline
## Baseline - by PASE group
##
## ====================================================================
## ====================================================================
# Step 0: labels
## ====================================================================
# lbs<-var.labels[match(colnames(X_tbl),
# names(var.labels))]
#
# ls<-lapply(1:ncol(X_tbl),function(x){
# as.formula(paste0(names(lbs)[x],"~","\"",lbs[x],"\""))
# })
#
# ts<-tbl_summary(X_tbl|>filter(pase_0_cut!="1"),
# by = "group",
# missing = "no",
# # label = ls[-length(ls)], ## Removing the last, as this is output
# value = list(where(is.factor) ~ "2"),
# type = list(mrs_0 ~ "categorical"),
# statistic = list(all_continuous() ~ "{median} ({p25};{p75}) [{min},{max}]")
# )%>%
# add_overall() %>%
# add_n()%>%
# as_gt()
#
# ts
#
# ts_rtf <- file("table1.RTF", "w")
# writeLines(ts%>%as_rtf(), ts_rtf)
# close(ts_rtf)
## ====================================================================
# Step 1: labels
## ====================================================================
# lbs<-var.labels[match(colnames(X_tbl_f), names(var.labels))]
#
# ls<-lapply(1:ncol(X_tbl_f),function(x){
# as.formula(paste0(names(lbs)[x],"~","\"",lbs[x],"\""))
# })
## ====================================================================
# Step 2: table - edited
## ====================================================================
# ts_e<-tbl_summary(X_tbl,
# missing = "no",
# value = list(where(is.factor) ~ "2"),
# type = list(mrs_0 ~ "categorical",
# mrs_1 ~ "categorical"),
# statistic = list(all_continuous() ~ "{median} ({p25};{p75}) [{min},{max}]")
# )%>%
# as_gt()
#
# ts_e
## ====================================================================
# Step 3: table export
## ====================================================================
# ts_rtf <- file("table1_overall.RTF", "w")
# writeLines(ts%>%as_rtf(), ts_rtf)
# close(ts_rtf)
## ====================================================================
# Baseline table - by PASE group
## ====================================================================
ts_q <- X_tbl |>
select(vars) |>
mutate(pase_0_cut = factor(quantile_cut(pase_0, groups = 4)[[1]],ordered = TRUE)) |>