Skip to content

How to avoid ifelse statement converting factor to character

2 messages · clint, David Winsemius

#
most all those posts were right in sourcing the problem....its just that
nobody actually offered a viable solution

the problem is that the new level "C" was not one of the original levels in
$social status

add "C" as a level and then just do the ol fashioned way and it works just
fine

do this:
data$SOCIAL_STATUS <- factor(data$SOCIAL_STATUS, levels =
c(levels(data$SOCIAL_STATUS), "C"))

then this:
data$SOCIAL_STATUS<-ifelse(data$SOCIAL_STATUS=="B" & data$MALE>4, "C", 
data$SOCIAL_STATUS)  

it is sooo much more helpful when someone who has addressed the specific
problem being asked replies instead of people just throwing random ideas out
there


--
View this message in context: http://r.789695.n4.nabble.com/How-to-avoid-ifelse-statement-converting-factor-to-character-tp895726p3992067.html
Sent from the R help mailing list archive at Nabble.com.
#
On Nov 4, 2011, at 7:33 PM, clint <clint at ucsd.edu> wrote:

            
Very few problems that are posed with a test dataset go unanswered.
Just a little Friday night trolling? This was a posting from 2 years ago.