Bioconductor Digest, Vol 118, Issue 25
0
0
Entering edit mode
@federicocomoglio-4524
Last seen 7.4 years ago
Switzerland
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]]
• 768 views
ADD COMMENT

Login before adding your answer.

Traffic: 951 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6