I am trying to use dplyr::case_when within dplyr::mutate to create a new variable where I set some values to missing and recode other values simult
dplyr::case_when
dplyr::mutate
Try this ?
df %>% dplyr::mutate(new = dplyr::case_when(.$old == 1 ~ 5, .$old == 2 ~ NA_real_, TRUE~.$old)) > df old new 1 1 5 2 2 NA 3 3 3