Displaying 2 results from an estimated 2 matches for "social_status".
2009 Jun 23
2
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" & 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. See the below R output. Notice that there were
71 "...
2009 Jun 24
5
How to avoid ifelse statement converting factor to character
Hi R-helpers,
Please see the below R output.
The problem is that after running the ifelse statement, data$SOCIAL_STATUS
is converted from a factor to a character.
Is there some way I can avoid this conversion?
Thanks in advance, Mark Na
> str(data)
'data.frame': 2100 obs. of 11 variables:
$ DATE : Factor w/ 5 levels "4-Jun-09","7-May-09",..: 1 1 1 1 1 1
1 1 1 1 ...
$ PON...