[R] Performing repeated T tests in R
Rui Barradas
rui1174 at sapo.pt
Thu Apr 19 21:29:30 CEST 2012
Hello,
>
> #I wrote a blank matrix with 1 row and 10000 columns.
>
Why not a vector? (It would be a column vector, which might not fit your
needs.)
And though not really a problem, the matrix is called 't', the name of R's
transpose function.
I can become confusing, maybe you could call it 'tstat' or something like
that.
>
> #But i need to do this for all 10000 pairs of samples:
> #I tried to write a loop
>
> for(j in 1:10000) {t[,1:10000]<-t.test(sampc1[, j],sampc2[, j])$statistic}
>
> #but this fills each column in the matrix with the same exact t value.
>
And that value is the test statistic of the last test.
This is because the index of the results matrix/row vector should be
for(j in 1:10000) {t[, j]<-t.test(sampc1[, j],sampc2[, j])$statistic}
Or, since it has only one row, t[1, j]
Or, with the suggestions above,
tstat <- double(10000)
for(j in 1:10000) {tstat[j]<-t.test(sampc1[, j],sampc2[, j])$statistic}
Hope this helps
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/Performing-repeated-T-tests-in-R-tp4571860p4571923.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list