Entering edit mode
Hi Wei,
if you want to obtain the correlation between your vector, say v, and
each of the columns of a matrix (M) you can simply use the cor
function on the augmented matrix having your vector as first column
and all the original columns of M following as [v M]. You then need to
store only the first column (or row, correlation matrices are
symmetric) of the resulting correlation matrix, on which you can
compute several summary statistics as you wish.
I attach a simple example.
Hope this helps,
Federico
M <- matrix(runif(100, 0,1), ncol = 10) #a 10x10 matrix
v <- 1:10
C <- cor( cbind(v, M) )[, 1]
mean(C)
sd(C)
Federico Comoglio
[[alternative HTML version deleted]]