full <- full %>% mutate(Title = case_when( Title %in% c('Mlle', 'Ms') ~ 'Miss', Title == 'Mme' ~ 'Mrs', Title %in% rare_title ~ 'Rare Title', TRUE ~ Title ))
The code above gives an error: Error in eval(substitute(expr), envir, enclos) : object 'Title' not found
However, the code below works. Is the name of the data frame inside case_when (makes the code more verbose).
full <- full %>% mutate(Title = case_when( full$Title %in% c('Mlle', 'Ms') ~ 'Miss', full$Title == 'Mme' ~ 'Mrs', full$Title %in% rare_title ~ 'Rare Title', TRUE ~ full$Title ))
source share