An ugly solution (but which works) would be something like this (assuming that d is a data.frame with 4 columns named Tank, Trt, Fish, Size):
x <-1:12 for (i in 1:12) x[i] <- mean(d$Size[d$Tank == i]) Regards, Moshe Olshansky --- Ronaldo Reis Junior <[EMAIL PROTECTED]> 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) > > 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 | > [EMAIL PROTECTED] | [EMAIL PROTECTED] > | http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | > LinuxUser#: 205366 > > ______________________________________________ > [email protected] 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. > ______________________________________________ [email protected] 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.
