I am trying to simplify data analysis by combining levels of a categorical variables.
There are 6 levels in this variable Let's say the name of this variable is "candle" and the levels are: "Always", "Nearly always", "Sometimes", "Seldom", "Never", "Never used", NA
I wanted to regroup "Always" and "Nearly Always" as "Yes", leave "Sometimes" as it is, and "Seldom" and "Never" with "No"
I used:
data <- data %>%
mutate(candle_new = ifelse(candle == "Always", "Yes", ifelse(candle == "Nearly always", "Yes", ifelse(candle == "Sometimes", "St",
ifelse(candle == "Never", "No", ifelse(candle == "seldom", "No", NA))))))
Although it runs and does not show any error message, when I check the original data, it does not seem like it worked.
Could you help me to figure out what I did wrong?
Thank you!