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?
cheers,
Rolf
r.turner at auckland.ac.nz
######################################################################
Attention:\ This e-mail message is privileged and confidenti...{{dropped}}
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