Hello, I have a data.frame: name col1 col2 col3 col4 AA 23 54 0.999 0.78 BB 123 5 1 0.99 AA 203 98 0.79 0.99 I want to get mean value data.frame in terms of name: name col1 col2 col3 col4 AA 113.0000 76.0000 0.8945 0.8850 BB 123.00 5.00 1.00 0.99 I tried to use by function:>aa<-by(test[,2:5], feature, mean)I found aa is "by" function.> class(aa)[1] "by" how can I transfer aa to a data frame? thanks YU [[alternative HTML version deleted]]
Hi
you could try
do.call('rbind',aa)
then turn the matrix into data frame
regards
Tengfei
On Wed, Apr 28, 2010 at 10:56 PM, Yuan Jian <jayuan2008@yahoo.com> wrote:
> Hello,
>
> I have a data.frame:
> name col1 col2 col3 col4
> AA 23 54 0.999 0.78
> BB 123 5 1 0.99
> AA 203 98 0.79 0.99
>
> I want to get mean value data.frame in terms of name:
>
> name col1 col2 col3 col4
>
> AA 113.0000 76.0000 0.8945 0.8850
>
> BB 123.00 5.00 1.00 0.99
>
> I tried to use by function:
>
> >aa<-by(test[,2:5], feature, mean)
> I found aa is "by" function.
> > class(aa)
> [1] "by"
>
> how can I transfer aa to a data frame?
>
> thanks
> YU
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Tengfei Yin
MCDB PhD student
1620 Howe Hall, 2274,
Iowa State University
Ames, IA,50011-2274
Homepage: www.tengfei.name
[[alternative HTML version deleted]]
Hi r-help-bounces at r-project.org napsal dne 29.04.2010 05:56:23:> Hello, > > I have a data.frame: > name col1 col2 col3 col4 > AA 23 54 0.999 0.78 > BB 123 5 1 0.99 > AA 203 98 0.79 0.99 > > I want to get mean value data.frame in terms of name: > > name col1 col2 col3 col4 > > AA 113.0000 76.0000 0.8945 0.8850 > > BB 123.00 5.00 1.00 0.99 > > I tried to use by function: > > >aa<-by(test[,2:5], feature, mean) > I found aa is "by" function. > > class(aa) > [1] "by" > > how can I transfer aa to a data frame?use aggregate instead aa<-aggregate(test[,2:5], feature, mean) Regards Petr> > thanks > YU > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.