Skip to content
Prev 138315 / 398506 Next

Calculating the t-test for each row

If I understand you correctly what you want to do is
do t-test (mu=0) for each column of the data. 

Treating the data as a data.frame rather than a matrix
you can do something like this and then pick out the
p-values but with 140 t-tests I don't know what you'll
get in terms of anything meaninful.  

======================================================


aa <- data.frame(a=rnorm(25, 5, 2), b=rnorm(1:25,
0,1))
mytea <- apply(aa, 2, t.test)

tresults <- lapply(mytea, function(.tres) {      
 
data.frame(t.value=.tres[1],dfs=.tres[2],conf.int1=.tres$conf.int[1],conf.int2=
 .tres$conf.int[2],p.value=.tres[3])
      })

finalresults <- do.call(rbind, tresults) 

=====================================================
(Thanks to Mark Leeds for the lapply approach)
--- Keizer_71 <christophe.lo at gmail.com> wrote:

            
data.matrix[order(variableprobe,decreasing=TRUE),][1:10000,]
http://www.nabble.com/Calculating-the-t-test-for-each-row-tp15808716p15808716.html