un...@r-project.org] Im
Auftrag von Mark Na
Gesendet: Tuesday, June 23, 2009 6:33 PM
An: r-help@r-project.org
Betreff: [R] Problem with ifelse statement
Hi R-helpers,
I am trying to use this ifelse statement to recode a variable:
> data$SOCIAL_STATUS<-ifelse(data$SOCIAL_STATUS=="B&qu
Notice what happens in your 'ifelse': any row that does not meet the
condition is changed to "B"; that is probably not what you were expecting.
You probably want:
data$SOCIAL_STATUS<-ifelse(data$SOCIAL_STATUS=="B" & data$MALE>4, "C",
data$SOCIAL_STATUS)
so you leave the others unchanged.
On Tu
Hi R-helpers,
I am trying to use this ifelse statement to recode a variable:
> data$SOCIAL_STATUS<-ifelse(data$SOCIAL_STATUS=="B" & data$MALE>4, "C", "B")
(i.e., if social status is B and there are more than 4 males, then
recode social status to C; otherwise, leave it B)
But, it's not working. S
3 matches
Mail list logo