How to reclassify variables?

I want to reclassify the contents within one variable (BS3_1_1) in the data (knhanes_age_42_N), but it doesn't work well.
Previously, I removed the missing values as na.omit.
knhanes_age_42_N<-transform(knhanes_age_42_N, smoke=ifelse(BS3_1_1=="1" & BS3_1_1=="2", "smoke3", ifelse(BS3_1_1=="3", "smoke2", ifelse(BS3_1_1=="8", "smoke1"))))

I would like to classify "1" and "2" in the variable as "smoke1", classify "3" as "smoke2", and finally reclassify "8" as "smoke3".

But it keeps coming out like the bottom.
Error in ifelse(BS3_1_1 == "8", "4") :
argument "no" is missing, with no default

I need help because it's my first rstudio.


Welcome to the RStudio community!

In order for us to help you with your question, please provide us a minimal reproducible example where you provide a minimal (dummy) dataset and code that can recreate the issue. Once we have that, we can go from there. For help on creating a Reprex, see this guide:

Good luck!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.