# Re: [R] anova on data means

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Thu, 21 Jun 2007 22:41:36 +0200

Ronaldo Reis Junior wrote:
> Em Quinta 21 Junho 2007 16:56, Thomas Miller escreveu:
>
>> I am transitioning from SAS to R and am struggling with a relatively simple
>> analysis. Have tried Venables and Ripley and other guides but can't find a
>> solution.
>>
>> I have an experiment with 12 tanks. Each tank holds 10 fish. The 12 tanks
>> have randomly assigned one of 4 food treatments - S(tarve), L(ow), M(edium)
>> and H(igh). There are 3 reps of each treatment. I collect data on size of
>> each fish at the end of the experiment. So my data looks like
>>
>> Tank Trt Fish Size
>> 1 S 1 3.4
>> 1 S 2 3.6
>> ....
>> 1 S 10 3.5
>> 2 L 1 3.4
>> ....
>> 12 M 10 2.1
>>
>> To do the correct test of hypothesis using anova, I need to calculate the
>> tank means and use those in the anova. I have tried using tapply() and
>> by() functions, but when I do so I "loose" the treatment level because it
>> is categorical. I have used
>> Meandat<tapply(Size,list(Tank, Trt), mean)
>>
>> But that doesn't give me a dataframe that I can then use to do the actual
>> aov analysis. So what is the most efficient way to accomplish the analysis
>>
>> Thanks
>>
>> Tom Miller
>>
>
> Tom,
>
> try the aggregate funtion. Somethink like this
>
> meandat <- aggregate(Size,list(Tank,Trt),mean)
>

Why not just include an error term for Tank in the model?

summary(aov(Size~Trt+Error(Tank)))

> Inte
> Ronaldo
> --
>
>> Prof. Ronaldo Reis Júnior
>>
> | .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Ecologia
> | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
> | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
> | `- Fone: (38) 3229-8187 | ronaldo.reis_at_unimontes.br | chrysopa_at_gmail.com
> | http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366
>
> ______________________________________________
> R-help_at_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
> and provide commented, minimal, self-contained, reproducible code.
>

R-help_at_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 and provide commented, minimal, self-contained, reproducible code. Received on Thu 21 Jun 2007 - 20:46:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Jun 2007 - 21:32:38 GMT.

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