Skip to content

Mean calculation of groups

3 messages · Nico Met, Bert Gunter, Rui Barradas

#
Nico:

1. Thanks for the example.

2. Please read -- or at least peruse -- the tutorial, An Introduction
to R (or other tutorial that you might find on the Web, there are
many) to familiarize yourself with R's features.

3. This is an example of what the apply() family of functions can do,
so you might want to find out about that (Google is your friend here).
?lapply would get you started with R's Help, but that's rather dense.

4. You may also want to look at the plyr package which has organized
and standardized in a convenient way much of the disparate
functionality of the apply-type functions.

5. Finally, to answer your question, ?ave.

Cheers,
Bert
On Tue, Sep 25, 2012 at 7:37 AM, Nico Met <nicomet80 at gmail.com> wrote:

  
    
#
Hello,

Or ?tapply.
ave will return a vector with the length of the input, tapply just one 
value per group.


ave(test$Score, test$Name, FUN = mean)  # 24 values
tapply(test$Score, test$Name, FUN = mean)  # 3 values

Hope this helps,

Rui Barradas

Em 25-09-2012 15:54, Bert Gunter escreveu: