48 lines
No EOL
1.4 KiB
R
48 lines
No EOL
1.4 KiB
R
create_flowchart <- function(data, export.path = NULL) {
|
|
out <- data |>
|
|
dplyr::select(pase_0,pase_4) |>
|
|
dplyr::mutate(id= dplyr::row_number(),
|
|
exclude=is.na(pase_0)|is.na(pase_4),
|
|
exclude_reason=factor(dplyr::case_when(
|
|
is.na(pase_0) ~ "Pre-stroke PASE missing",
|
|
is.na(pase_4) ~"Post-stroke PASE missing"
|
|
),levels=c( "Pre-stroke PASE missing","Post-stroke PASE missing")),
|
|
) |>
|
|
consort::consort_plot(
|
|
orders = c(
|
|
id = "Complete TALOS cohort",
|
|
exclude_reason = "Excluded",
|
|
id = "Main dataset"
|
|
),
|
|
side_box = c("exclude_reason"),
|
|
labels = c(
|
|
"1" = "Identification",
|
|
"2" = "Inclusion",
|
|
"3" = "Complete data"
|
|
)
|
|
)
|
|
|
|
if (!is.null(export.path)) {
|
|
out |> export_consort_dot(path = export.path)
|
|
} else {
|
|
plot(out)
|
|
}
|
|
}
|
|
|
|
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"))
|
|
|
|
df <- 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))
|
|
|
|
df |> create_flowchart() |