I have been having issues with trying to convert words to numerical values. I cannot find for the life of me what is going wrong. My code looks like below:
df1 <- df1 %>%
mutate(income_num = case_when(
IncomeGroup == "Low income" ~ 1,
IncomeGroup == "Lower middle income" ~ 2,
IncomeGroup == "Upper middle income" ~ 3,
"TRUE" ~ 4))
My hope is to give a numerical value to the different types of incomes but I keep on getting this error message:
Error: Problem with mutate()
input income_num
. x object 'IncomeGroup' not found i Input income_num
is case_when(...)
. Run rlang::last_error()
to see where the error occurred.
Help will very much be appreciated.