I'm trying to change cell entries when a column and cell meets criteria.
Data:
df <- data.frame(a=c("a", "ab", "ac"), b=c("b", "bc", NA), c=c("c", NA, "cda")) > df a b c 1 a b c 2 ab bc <NA> 3 ac <NA> cda Attempt:
> df %>% mutate(across(matches("b", "c"), ~case_when(. %in% "c" & is.na(.) ~ "here", TRUE ~ as.character(.)))) a b c 1 a b c 2 ab bc <NA> 3 ac <NA> cda Looking for this:
a b c 1 a b c 2 ab bc here 3 ac here cda