Re: [Rd] Aggregate factor names

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu, 27 Sep 2007 12:06:09 -0400

You can do this:

aggregate(iris[-5], iris[5], mean)

On 9/27/07, Mike Lawrence <Mike.Lawrence_at_dal.ca> wrote:
> Hi all,
>
> A suggestion derived from discussions amongst a number of R users in
> my research group: set the default column names produced by aggregate
> () equal to the names of the objects in the list passed to the 'by'
> object.
>
> ex. it is annoying to type
>
> with(
> my.data
> ,aggregate(
> my.dv
> ,list(
> one.iv = one.iv
> ,another.iv = another.iv
> ,yet.another.iv = yet.another.iv
> )
> ,some.function
> )
> )
>
> to yield a data frame with names = c
> ('one.iv','another.iv','yet.another.iv','x') when this seems more
> economical:
>
> with(
> my.data
> ,aggregate(
> my.dv
> ,list(
> one.iv
> ,another.iv
> ,yet.another.iv
> )
> ,some.function
> )
> )
>
> --
> Mike Lawrence
> Graduate Student, Department of Psychology, Dalhousie University
>
> Website: http://memetic.ca
>
> Public calendar: http://icalx.com/public/informavore/Public
>
> "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-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 27 Sep 2007 - 16:08:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 27 Sep 2007 - 18:41:40 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.