Re: [R] apply, t-test and p-values PREVIOUS SUGGESTION DID NOT WORK

2008-10-16 Thread Jorge Ivan Velez
Dear John, Perhaps is possible to do the job using apply or any of its friends. For now, here is a solution using for() : # Data sets set.seed(123) sample1<-matrix(data=c(1:20),byrow=TRUE,ncol=5,nrow=4) sample2<-sample1+rnorm(20) # t-test p-values k=nrow(sample1) res=NULL for(i in 1:k) res[i]=t.t

Re: [R] apply, t-test and p-values PREVIOUS SUGGESTION DID NOT WORK

2008-10-16 Thread Gábor Csárdi
How about the following? sapply(1:nrow(sample1), function(x) t.test(sample1[x,], sample2[x,])$p.value) Gabor On Thu, Oct 16, 2008 at 6:07 PM, John Sorkin <[EMAIL PROTECTED]> wrote: > Although I am grateful to Jorge and David for their suggestions, their > solution will not solve my problem as s

Re: [R] apply, t-test and p-values PREVIOUS SUGGESTION DID NOT WORK

2008-10-16 Thread John Sorkin
Although I am grateful to Jorge and David for their suggestions, their solution will not solve my problem as sample2 is not fixed. Let me demonstrate what I want to do: # Define two matricies sample1<-matrix(data=c(1:20),byrow=TRUE,ncol=5,nrow=4) sample2<-sample1+rnorm(20) These are the comput