[R] average by group...

From: r user <ruser2006_at_yahoo.com>
Date: Wed 31 May 2006 - 02:27:03 EST


I have a dataframe with 700,000 rows and 2 vectors
(columns): “group” and “score”.

I wish to calculate a third vector of length 700000: the average score by group. Even though the avarge value will repeat, I wish to return the average for that particular group for each row.

(I know I can do this by calculating each group’s
average and then using the merge command, but as my calculations get more complex and my data set gets larger, the merge command seems to be fairly slow.)



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed May 31 02:32:12 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 Wed 31 May 2006 - 04:10:21 EST.

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