[Rd] Why is there no c.factor?

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Fri Feb 5 16:41:08 CET 2010

Hadley Wickham wrote:
> On Thu, Feb 4, 2010 at 12:03 PM, Hadley Wickham <hadley at rice.edu> wrote:
>>> I'd propose the following: If the sets of levels of all arguments are the
>>> same, then c.factor() would return a factor with the common set of levels;
>>> if the sets of levels differ, then, as Hadley suggests, the level-set of the
>>> result would be the union of sets of levels of the arguments, but a warning
>>> would be issued.
>> I like this compromise (as long as there was an argument to suppress
>> the warning)
> If I provided code to do this, along with the warnings for ordered
> factors and using the optimisation suggested by Matthew, is there any
> member of R core would be interested in sponsoring it?
> Hadley

Messing with c() is a bit unattractive (I'm not too happy with the other
c methods either; normally c() strips attributes and reduces to the base
class, and those obviously do not), but a more general concat() function
has been suggested a number of times. With a suitable range of methods,
this could also be used to reimplement rbind.data.frame (which,
incidentally, already contains a method for concatenating factors, with
several ugly warts!)

   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907

More information about the R-devel mailing list