[R] Odp: Reg : using two different matrix : how to do t.test
Petr PIKAL
petr.pikal at precheza.cz
Mon Nov 19 09:42:16 CET 2007
Hi
r-help-bounces at r-project.org napsal dne 19.11.2007 09:32:25:
> I have two matrix with same dimensions. I want to do t.test using each
column
> from 2 different matrix.
> Row n Column names in both matrix are same.
>
> e.g.
> Matrix1
> id VC1 VC2 VC3
> R 1 2 3
> R1 4 5 6
> R3 7 8 9
>
>
> Matrix2
> id VC1 VC2 VC3
> R 10 11 12
> R1 13 14 15
> R3 16 17 18
>
> want to do t.test using each column (with same name ) using Matrix1 and
Matrix2
>
> for eg t.test(Matrix1$VC1, Matrix2$VC1)$p.value
I am not sure if it is a best way but here seems to me that for cycle
could be considered
result<-rep(NA, 3999)
for (i in 2:4000) {
result [i-1] <- t.test(mat1[,i], mat2[,i])$p.value
}
Regards
Petr
>
> What is the best way to do it. I have dataset with 4000 columns for each
> matrix with same row and column names.
>
> Thanks a lot.
>
> ---------------------------------
> Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try
it now.
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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