[R] Creating Dummy Var in R for regression?
shivipmp82 at gmail.com
Fri Aug 5 20:50:05 CEST 2016
I need help with the below code in R:
gender_rec<- c('Dr','Father','Mr'=1, 'Miss','MS','Mrs'=2, 3)
This code gives me the correct output but it overwrites the
reason$salutation variable. I need to create a new variable gender to
capture gender details and leave salutation as it is.
i tried the below syntax but it is converting all to 1.
reasons$gender<- ifelse(reasons$salutation== "Mr" & reasons$salutation==
"Father","Male", ifelse(reasons$salutation=="Mrs" & reasons$salutation==
[[alternative HTML version deleted]]
More information about the R-help