Similar to the previous issue:
# Start with the linelist:
linelist <- linelist %>%
# Create ate_anything column:
mutate(ate_anything = case_when(
# ate_anything = FALSE if none of the exposure columns are TRUE:
if_all(.cols = all_of(exposure_cols),
.fns = ~ !. %in% c(TRUE)) ~ FALSE,
# ate_anything = TRUE if any of the exposure columns are TRUE:
if_any(.cols = any_of(exposure_cols),
.fns = ~ . == TRUE) ~ TRUE
))
Alternative
# Start with the linelist:
linelist <- linelist %>%
# Create ate_anything column:
mutate(ate_anything = case_when(
# ate_anything = TRUE if any of the exposure columns are TRUE:
if_any(.cols = any_of(exposure_cols),
.fns = ~ . == TRUE) ~ TRUE,
TRUE ~ FALSE
))
Similar to the previous issue:
Alternative