[R] compute pearson correlation p-values for all combinations of columns of 2 matrices

Daren Tan daren76 at hotmail.com
Tue Nov 25 13:14:14 CET 2008


How can I compute the pearson correlation p-values for all combinations of columns of 2 matrices ?
  
 
> m <- matrix(rnorm(20), nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
> m1 <- matrix(rnorm(20), nrow=4, dimnames=list(LETTERS[1:4], letters[1:5]))
> cor(m,m1)
            a          b          c           d           e
a -0.67533294 -0.2516151 -0.3780815  0.55816011 -0.16526501
b  0.41729336  0.1078082  0.6671405 -0.81381931 -0.20240428
c -0.01058068 -0.5069489  0.7723080 -0.79558376 -0.32441411
d  0.98691269  0.8147252 -0.2853724  0.05879335  0.63893235
e  0.59140305  0.6746471  0.2835064 -0.47762034 -0.06372043



More information about the R-help mailing list