[Rd] c.factor

Bill Dunlap bill at insightful.com
Wed Nov 15 18:24:48 CET 2006


> > In addition, c() has always had a double meaning of
> >  (a) turning an object into a simple "vector" (an object
> >      without "attributes"), as in
> >      > c(factor(c("Cat","Dog","Cat")))
> >      [1] 1 2 1
> >      > c(data.frame(x=1:2,y=c("Dog","Cat")))
> >      $x
> >      [1] 1 2
> >
> >      $y
> >      [1] Dog Cat
> >      Levels: Cat Dog
>
> To my surprise that was not documented at all on the R help page, and I've
> clarified it.  (BTW, at least in R it does not remove names, just all
> other attributes.)

It does not remove names in Splus either, just all
other attributes.  I see c() used in several Splus
functions as a way to convert a matrix into a vector
(by removing the .Dims and .Dimnames attributes).

> I think working on a concat() for R would be helpful.  I vaguely recalled
> something like it in the Green Book, but the index does not help (but then
> it is not very complete).

Splus does have a concat().  I believe it is modelled
after the Green Book example.  It uses a helper function
called concat.two(x,y) with is generic and has 2 arguments
to make it easer to write methods for.  concat(x,y,z)
calls concat.two(concat.two(x,y),z).  concat() is not used much,
but it is the Summary group functions: min, max, sum, etc.

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."



More information about the R-devel mailing list