It may be poor form, but whenever I deal with factors in this way I find as.character and as.numeric useful
ex. #if your factor levels are letters z=factor(unique(c(as.character(x),as.character(y)))) #if your factor levels are numbers z=factor(unique(c(as.numeric(as.character(x)),as.numeric(as.character (y))))) On 22-May-07, at 11:56 PM, Marc Schwartz wrote: > On Wed, 2007-05-23 at 13:38 +1200, Rolf Turner wrote: >> >> I was recently asked by one of new colleagues how to combine, or >> catentate, >> or concatentate two factors. If x and y are factors, doing c(x,y) >> appears >> to coerce x and y to numeric mode before catenating them. So what >> does one >> do if one wants the result to be a factor whose levels are the >> union of the >> levels of x and y? I vaguely recall seeing this discussed in r- >> help, but I >> can't find anything on it there, nor in the FAQ. >> >> Am I missing something obvious? > > Rolf, > > I think that this thread from last November on R-devel may be helpful: > > http://tolstoy.newcastle.edu.au/R/e2/devel/06/11/1130.html > > HTH, > > Marc Schwartz > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. -- Mike Lawrence Graduate Student, Dalhousie University Department of Psychology http://myweb.dal.ca/mc973993 "The road to wisdom? Well, it's plain and simple to express: Err and err and err again, but less and less and less." - Piet Hein ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.