Could someone help me regarding the use of ifelse.
ifelse
I have a data.frame (dat) with a categorical variable/factor called Q1 (dat$Q1
data.frame
dat$Q1
Use ifelse as in:
dat$new1 <- ifelse(dat$Q1==3, 1, 0)
Just:
dat$new1 <- 0+(dat$Q1==3) # or use as.numeric(.)