[R] Row-wise two sample T-test on subsets of a matrix

Nameeta Lobo nlobo at uchicago.edu
Thu Mar 1 18:51:29 CET 2007


Hello all,

I am trying to run a two sample t-test on a matrix which is a
196002*22 matrix. I want to run the t-test, row-wise, with the
first 11 columns being a part of the first group and columns
12-22 being a part of the second group. 

I tried running something like (temp.matrix being my 196002*22
matrix)

t.test(temp.matrix[,1:11],temp.matrix[,12:22],paired=TRUE)

or somthing like

as.numeric(t.test(temp.matrix[,1:11],temp.matrix[,12:22],paired=TRUE)[[1]])
so as to only capture the t-value alone and 

and I get a result for the whole matrix instead of a row-wise
result. 

I want to avoid using a "for" loop to increment the number of
rows as it would take a huge amount of time.


Any suggestions would be really appreciated.

thanks
nameeta



More information about the R-help mailing list