I have a question regarding the combination of several ifelse functions in R. When attempting to run the following line, I get a result of only "Other".
standardized_object_codes <- ifelse(Spending_1$OBJECT_CODE %in% c("GG"), "Grants",
ifelse(Spending_1$OBJECT_CODE %in% c("SW"),"Salaries and Wages",
ifelse(Spending_1$OBJECT_CODE %in% c("DR"), "Retirement",
ifelse(Spending_1$OBJECT_CODE %in% c("DO"), "Nonretirement",
ifelse(Spending_1$OBJECT_CODE %in% c("PC"), "Contracts", "Other")))))
This is definitely not normal as my data contains all of the object codes that are listed in the function above (GG, SW, DR, DO and PC). Could you please help me out with what I am doing wrong?
Thanks a lot!