PAaSO/1 PA Decline/summaries.qmd

109 lines
2.6 KiB
Text
Raw Normal View History

2026-08-19 09:27:27 +02:00
---
title: "Article A: Final renders"
format: docx
editor: visual
---
```{r}
# ds <- readr::read_csv(here::here("/Volumes/Data/REDCap/DDV/talos_ddv.csv"))
source(here::here("2 Longterm/data.R"))
# The original functions from DST unedited
source(here::here("1 PA Decline/Fra DDV/functions200411.R"))
source(here::here("1 PA Decline/Fra DDV/functions240418.R"))
# Modified functions to overwrite original
source(here::here("R/functions.R"))
```
Files and resources used for article ready data:
- "2 Longterm/data.R"
- "R/functions240319.R"
```{r}
# ds |> finalfit::missing_plot()
```
On handling missings: https://finalfit.org/articles/missing.html
```{r}
# unique(df_long$variable)
```
```{r}
pred_data <- df_ddv |>
dplyr::tibble() |>
dplyr::mutate_all(as.character) |>
ready_clin() |>
data_formatting() |>
prediction_ready() |>
dplyr::mutate(
dplyr::across(
c(
tidyselect::starts_with("pase_"),
"age"
),
as.numeric
)
)
pred_data |> labelling_data() |> readr::write_rds("labelled_test.rds")
skimr::skim(pred_data)
wilcox.test(pred_data$pase_0, pred_data$pase_4, paired = TRUE)
```
```{r}
pred_data |>
true_pred_sum_plot() |>
gtsummary::as_gt() |>
# add_var_groups_gt()|>
gt::gtsave(filename = here::here("1 PA Decline/table1.docx"))
system2("open",here::here("'1 PA Decline/table1.docx'"))
# gtsummary2docx(path=here::here("1 PA Decline/table1.docx"))
```
```{r}
pred_data |>
dplyr::mutate(reg_female = dplyr::if_else(reg_female, "Female", "Male")) |>
pase_cutter(drop.pase = FALSE) |>
dplyr::select(pase_change, dplyr::everything()) |>
summary_tblone(by = "reg_female", missing = "no") |>
gtsummary::modify_column_hide("stat_0") |>
gtsummary::add_p() |>
gtsummary::bold_p() |>
micRo::mask_micro_summary() |>
gtsummary::as_gt() |>
gt::gtsave(filename = here::here("1 PA Decline/table_bysex.docx"))
```
```{r}
skimr::skim(pred_data)
```
## Excluded patients
```{r}
df_ddv |>
dplyr::tibble() |>
dplyr::mutate_all(as.character) |>
ready_clin() |>
data_formatting()|>
get_vars(c("clin","lifestyle","ses", "assess.pred")) |>
dplyr::mutate(exclude=ifelse(is.na(pase_0)|is.na(pase_4),"Excluded","Included"),
age=as.numeric(age),
pase_0=as.numeric(pase_0),
pase_4=as.numeric(pase_4)
)|>
# dplyr::select(-pase_0,-pase_4) |>
#dplyr::select(exclude,soc_status_nowork, fam_indk_hl, edu_level_hl)|>
gtsummary::tbl_summary(by=exclude, missing = "ifany") |>
gtsummary::add_p() |>
fix_labels() |>
gtsummary::as_gt() |>
gt::gtsave("1 PA Decline/summary_by_missing.docx")
#|>
# mask_micro_summary(micro.n = 5)
```