This question already has an answer here:
I'm actively trying to learn more R. I am familiar with coding dummy variables in this such way to use in regression analysis (example is from coding for region in panel data)
dum1<-ifelse(var=="condition",1,0)
What im wondering is why when i attempt to code it this way
if(variable=="condition"){dum1<-1} else {dum1<-0}
i get this: Warning message: In if (variable == "condition") { : the condition has length > 1 and only the first element will be used
Can someone help explain this to me? Thanks
Aucun commentaire:
Enregistrer un commentaire