Joseph F. Lucke
Senior Statistician
Research Institute on Addictions
University at Buffalo
SUNY
"Tan, Richard"
Sent by: r-help-boun...@r-project.org
02/12/2009 11:19 AM
To
cc
Subject
[R] get top 50 correlated item from a correlation matrix for each item
Hi,
I have a correlat
Works like a charm, thank you!
-Original Message-
From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl]
Sent: Thursday, February 12, 2009 12:11 PM
To: Tan, Richard
Cc: r-help@r-project.org
Subject: Re: [R] get top 50 correlated item from a correlation matrix
for each item
a
a possible vectorized solution is the following:
cor.mat <- cor(matrix(rnorm(100*1000), 1000, 100))
p <- 30 # how many top items
n <- ncol(cor.mat)
cmat <- col(cor.mat)
ind <- order(-cmat, cor.mat, decreasing = TRUE) - (n * cmat - n)
dim(ind) <- dim(cor.mat)
ind <- ind[seq(2, p + 1), ]
out <- cb
Hi,
I have a correlation matrix of about 3000 items, i.e., a 3000*3000
matrix. For each of the 3000 items, I want to get the top 50 items that
have the highest correlation with it (excluding itself) and generate a
data frame with 3 columns like ("ID", "ID2", "cor"), where ID is those
3000 items
4 matches
Mail list logo