Re: [Rd] c.factor

From: Bill Dunlap <bill_at_insightful.com>
Date: Wed 15 Nov 2006 - 17:24:48 GMT

> > 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."



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Nov 16 11:23:11 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 16 Nov 2006 - 00:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.