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 something fancy picking
up the name of the called function automatically, but
I mostly use an unnamed summary function (x) { ...}, so I won't
bother.

(BTW did I ever mention here how much I prefer with() to 
attach()/forget.to.detach() ?)

> From: Marc Schwartz [mailto:[EMAIL PROTECTED]
> Sent: 02 October 2003 15:37

> attach(df)
> aggregate(as.data.frame(treatment), 
>           list(group = group, duplicate = duplicate), mean)
> ### Remember to 'detach(df)'.
> 
> Doing it this way, 'treatment' retains the name attribute 
> when passed to aggregate, rather than as a vector.
 

Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 644449
Fax: +44 (0) 1379 644445
email: [EMAIL PROTECTED]
web: http://www.synequanon.com
 
Number of attachments included with this message: 0
 
This message (and any associated files) is confidential and\...{{dropped}}

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to