transfer from old repo
This commit is contained in:
parent
cfa4a5f9cc
commit
277e2b8cf3
1111 changed files with 83736 additions and 0 deletions
56
1 PA Decline/sankey individual.R
Normal file
56
1 PA Decline/sankey individual.R
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
ds <- readr::read_csv(here::here("/Volumes/Data/REDCap/DDV/talos_ddv.csv"))
|
||||
|
||||
df_raw <- ds |>
|
||||
dplyr::filter(!pase_score_missings_0, !pase_score_missings_4) |>
|
||||
dplyr::transmute(
|
||||
id = dplyr::row_number(),
|
||||
pase_0 = pase_score_sum_0,
|
||||
pase_4 = pase_score_sum_4,
|
||||
pase_0_cut = as.numeric(stRoke::quantile_cut(
|
||||
x = pase_0,
|
||||
groups = 4,
|
||||
group.names = paste0(1:4)
|
||||
)),
|
||||
pase_6_cut = as.numeric(stRoke::quantile_cut(
|
||||
x = pase_4,
|
||||
y = pase_0,
|
||||
groups = 4,
|
||||
inc.outs = TRUE,
|
||||
group.names = paste0(1:4)
|
||||
)),
|
||||
pase_diff = pase_4 - pase_0,
|
||||
pase_diff_rel = pase_diff / pase_0,
|
||||
pase_0_rank = rank(pase_0, ties.method = "first"),
|
||||
pase_4_rank = rank(pase_4, ties.method = "first"),
|
||||
change = dplyr::case_when(
|
||||
pase_0_cut %in% 2:4 & pase_6_cut == 1 ~ "drop",
|
||||
pase_6_cut %in% 2:4 & pase_0_cut == 1 ~ "hop",
|
||||
pase_0_cut %in% 2:4 & pase_6_cut %in% 2:4 ~ "hh",
|
||||
pase_0_cut %in% 1 & pase_6_cut == 1 ~ "ll"
|
||||
),
|
||||
change_any = factor(dplyr::case_when(
|
||||
pase_6_cut > pase_0_cut ~ "hop",
|
||||
pase_6_cut < pase_0_cut ~ "drop",
|
||||
pase_0_cut %in% 2:4 & pase_6_cut %in% 2:4 ~ "hh",
|
||||
pase_0_cut %in% 1 & pase_6_cut == 1 ~ "ll"
|
||||
)),
|
||||
change_rel = factor(dplyr::case_when(
|
||||
pase_diff_rel > .5 ~ "hop",
|
||||
pase_diff_rel < -.5 ~ "drop",
|
||||
.default = "stat"
|
||||
))
|
||||
)
|
||||
|
||||
df_raw |> skimr::skim()
|
||||
|
||||
df_long <- df_raw |>
|
||||
dplyr::select(pase_0_rank, pase_4_rank, change_rel,id) |>
|
||||
tidyr::pivot_longer(dplyr::starts_with("pase_"), names_to = "time", values_to = "pase")
|
||||
|
||||
df_long <- df_raw |>
|
||||
dplyr::select(pase_0, pase_4, change_rel,id) |>
|
||||
tidyr::pivot_longer(dplyr::starts_with("pase_"), names_to = "time", values_to = "pase")
|
||||
|
||||
ggplot(df_long, aes(x = time, y = pase,group=id,colour = change_rel)) +
|
||||
geom_line()+
|
||||
facet_wrap(~change_rel)
|
||||
Loading…
Reference in a new issue