[R] average by group...

r user ruser2006 at yahoo.com
Tue May 30 18:27:03 CEST 2006


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



More information about the R-help mailing list