string - Find and replace in R for categorical variables -
this question has answer here:
- replace values in vector based on vector 2 answers
x1 <- c("agree","disagree","agree","agree","agree","disagree","disagree") how replace agree=1 , disagree=0 large atomic vectors or specific row/columns in data frame?
you can this
ifelse(x1 == 'agree', 1, 0) more conditions can added necessary.
Comments
Post a Comment