[R] aggregate data.frame by one column

Guo Wei-Wei wwguocn at gmail.com
Fri Jun 30 06:23:43 CEST 2006


Hi Andrew,

Thank you very much! It works so well than I can expect.

All the best,
Wei-Wei

2006/6/30, Andrew Robinson <A.Robinson at ms.unimelb.edu.au>:
> Hi Wei-Wei,
>
> try this:
>
> eva.agg <- aggregate(x = list(
>                        VC1=eva$VC1,
>                        EO1=eva$EO1,
>                        EO2=eva$EO2,
>                        EO3=eva$EO3,
>                        EO4=eva$EO4,
>                        EO5=eva$EO5
>                        ),
>                      by = list(PARTNO=eva$PARTNO),
>                      FUN = mean, na.rm = TRUE)
>
> eva.agg$NUM <- aggregate(eva$PARTNO, list(eva$PARTNO), length)
>
> Cheers
>
> Andrew
>



More information about the R-help mailing list