[R] Row-wise two sample T-test on subsets of a matrix
Ranjan Maitra
maitra at iastate.edu
Thu Mar 1 19:48:29 CET 2007
Here's one suggestion: convert the matrix into a three-dimensional array and use apply on it.
Ranjan
On Thu, 1 Mar 2007 11:51:29 -0600 (CST) Nameeta Lobo <nlobo at uchicago.edu> wrote:
> 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
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list