Re: [R] how calculate mean for each group

2003-10-02 Thread Spencer Graves
An alternative to renaming columns in the ouput of aggregate is to provide names in the by list as follows: aggregate(df$treatment, list(gp=df$group, dup=df$duplicate), mean) hope this helps. spencer graves Marc Schwartz wrote: On Wed, 2003-10-01 at 20:15, [EMAIL PROTECTED] wrote: Hello,

Re: [R] how calculate mean for each group

2003-10-02 Thread Marc Schwartz
On Thu, 2003-10-02 at 08:47, Spencer Graves wrote: An alternative to renaming columns in the ouput of aggregate is to provide names in the by list as follows: aggregate(df$treatment, list(gp=df$group, dup=df$duplicate), mean) hope this helps. spencer graves SNIP Spencer, Yeah, knew

RE: [R] how calculate mean for each group

2003-10-02 Thread Simon Fear
A little more succinctly and I hope also helpful: with(df, aggregate(list(mean=treatment), list(group = group, duplicate = duplicate), mean)) Note that the name of the summary of treatment is likely best to be different from the name of the treatment variable itself. It is tempting to do

RE: [R] how calculate mean for each group

2003-10-02 Thread Marc Schwartz
On Thu, 2003-10-02 at 10:11, Simon Fear wrote: A little more succinctly and I hope also helpful: with(df, aggregate(list(mean=treatment), list(group = group, duplicate = duplicate), mean)) Note that the name of the summary of treatment is likely best to be different from the name

Re: [R] how calculate mean for each group

2003-10-01 Thread Spencer Graves
Have you considered aggregate? hope this helps. spencer graves [EMAIL PROTECTED] wrote: Hello, R experts: I got data like this: group duplicate treatment A Y 5 A Y 3 A N 6 B Y 2 B N 4 B Y

Re: [R] how calculate mean for each group

2003-10-01 Thread Marc Schwartz
On Wed, 2003-10-01 at 20:15, [EMAIL PROTECTED] wrote: Hello, R experts: I got data like this: group duplicate treatment A Y 5 A Y 3 A N 6 B Y 2 B N 4 B Y 1 How to sort the data and