I have a data frame whose columns I want to retain as is, but mutate nonsensical values (i.e. daily calorie intake = 88888) to NA. I am trying to do this with dplyr, but cannot find a solution which combines the column names as a list or that match a prefix (all start with "DRPN"), and change the 88888 values to NA.
Tried mutate_if()
but the function will not take the list of columns.
Tried mutate_at()
but the function doesn't accept my requirements.
df_recode <- lab1_final %>%
select(vars(starts_with("DRPN")) %>%
mutate_if(vars, "88888", NA)
Which I am trying to get to swap the 88888 observations with NA so that I can properly analyze the continuous variables. Any ideas?