On 8/30/07, Sonia Mehault <[EMAIL PROTECTED]> wrote:
> Hello,
>
>
>
> My data are as following:
>
>
>
> Data <- data.frame(Ind=rep(1:3,c(10,10,10)),
>
>                    Replicate=rep(c(rep("a",5),rep("b",5)),3),
>
>                    EggSize=rep(rnorm(5,mean=10),6)
>
>                    )
>
> attach(Data)
>
>
>
>
>
> Using a t-test, I want to check if the mean egg sizes are significantly
> different between replicates a and b for each individuals (ie. In that case,
> 3 outputs with 3 p-values).
>
> I tried the following, but doesn't work:
>
>
>
>
>
> Fun <- function(x,y) {
>
>        print(t.test(x ~ y))
>
>        }
>
>
>
> tapply(EggSize,Ind,Fun(EggSize,Replicate))
>
>
>
>
>
> What should I do?
>
> Many thanks.



Is this what you want?


-----
eggdata<- data.frame(Ind=rep(1:3,c(10,10,10)),
                  Replicate=rep(c(rep("a",5),rep("b",5)),3),
                  EggSize=rnorm(30,mean=10)+rep(c(rep(1,5),rep(0,5)),3)
                  )

eggfun<-function(x){
print(t.test(x$EggSize~x$Replicate))
}

by(eggdata,eggdata$Ind,eggfun)

-------------


/Gustaf
-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

______________________________________________
R-help@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.

Reply via email to