select_group_tbl(data = stem_social_psych,
var_stem = "belong_belong",
group = "\\d",
group_type = "pattern",
group_name = "wave",
na_removal = "pairwise",
pivot = "wider",
only = "count")
tas_recoded <-
tas |>
dplyr::mutate(sex = dplyr::case_when(
sex == 1 ~ "female",
sex == 2 ~ "male",
TRUE ~ NA)) |>
dplyr::mutate(dplyr::across(
.cols = dplyr::starts_with("involved_"),
.fns = ~ dplyr::case_when(
.x == 1 ~ "selected",
.x == 0 ~ "unselected",
TRUE ~ NA)
))
select_group_tbl(data = tas_recoded,
var_stem = "involved_",
group = "sex",
group_type = "variable",
na_removal = "pairwise",
pivot = "wider")
depressive_recoded <-
depressive |>
dplyr::mutate(sex = dplyr::case_when(
sex == 1 ~ "male",
sex == 2 ~ "female",
TRUE ~ NA)) |>
dplyr::mutate(dplyr::across(
.cols = dplyr::starts_with("dep_"),
.fns = ~ dplyr::case_when(
.x == 1 ~ "often",
.x == 2 ~ "sometimes",
.x == 3 ~ "hardly",
TRUE ~ NA
)
))
select_group_tbl(data = depressive_recoded,
var_stem = "dep",
group = "sex",
group_type = "variable",
na_removal = "listwise",
pivot = "wider",
only = "percent",
var_labels =
c("dep_1" = "how often child feels sad and blue",
"dep_2" = "how often child feels nervous, tense, or on edge",
"dep_3" = "how often child feels happy",
"dep_4" = "how often child feels bored",
"dep_5" = "how often child feels lonely",
"dep_6" = "how often child feels tired or worn out",
"dep_7" = "how often child feels excited about something",
"dep_8" = "how often child feels too busy to get everything"))
Run the code above in your browser using DataLab