string - Find and replace in R for categorical variables -


this question has answer here:

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

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -