Skip to content

cross-correlation table with subscript or superscript to indicate significant differences

2 messages · yoav baranan, David Winsemius

#
On May 5, 2011, at 10:48 AM, yoav baranan wrote:

            
An example with data and the desired result might help focus the  
discussion.

This shows how to set up an example showing how extract the row  
numbers from a correlation matrix with absolute values above 0.5 but  
less than 1 (to exclude the trivial cases).

 > set.seed(123)
 > X <- matrix(rnorm(100), 10)
 > apply(cor(X), 2, function(x) which(abs(x) > 0.5 & x < 1)  )
[[1]]
[1] 2 4 8

[[2]]
[1] 1 3

[[3]]
[1] 2 6 9

[[4]]
[1] 1 7

[[5]]
integer(0)

[[6]]
[1]  3 10

[[7]]
[1] 4

[[8]]
[1] 1

[[9]]
[1] 3

[[10]]
[1] 6

This would extract the rownames if they are letters[1:10]

 > lapply( apply(cor(X), 2, function(x) which(abs(x) > 0.5 & x < 1) ),  
function(x) rownames(X)[x])
[[1]]
[1] "b" "d" "h"

[[2]]
[1] "a" "c"

[[3]]
[1] "b" "f" "i"

[[4]]
[1] "a" "g"

[[5]]
character(0)

[[6]]
[1] "c" "j"

[[7]]
[1] "d"

[[8]]
[1] "a"

[[9]]
[1] "c"

[[10]]
[1] "f"

Exactly how we are supposed to pass this to MS Word does not seem to  
be a proper question for this mailing list.