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

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -