[R] How to avoid ifelse statement converting factor to character
dwinsemius at comcast.net
Sat Nov 5 02:40:43 CET 2011
On Nov 4, 2011, at 7:33 PM, clint <clint at ucsd.edu> wrote:
> most all those posts were right in sourcing the problem....its just that
> nobody actually offered a viable solution
Very few problems that are posed with a test dataset go unanswered.
> 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
> 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",
> 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
Just a little Friday night trolling? This was a posting from 2 years ago.
> 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.
This is a mailing list. Nabble users who fail to include context who replying to ancient threads should not be throwing stones.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help