kparamas
2011-Jan-28 04:13 UTC
[R] Please help -- Converting a 2D matrix to 3 columns for graphical representation
Hi, I am trying to convert a 2D correlation matrix to 3 columns for graphical representation: rdata = replicate(100, rnorm(15)) #construct a 2D matrix c1 = cor(rdata) #outputs a correlation matrix Now I want to convert the 2D c1 to (row#, col#, correlation) 1 1 cor1 1 2 cor2 1 3 cor3 ... 2 1 cor.. Is there a way to do this? The main reason I am doing this is to find a correlation based graph for values >= 0.85 using, corm <- corm[abs(corm[,3]) >= 0.86, ] library(network); library(sna) net <- network(corm, directed = F) cd <- component.dist(net) delete.vertices(net, which(cd$csize[cd$membership] == 1)) plot(net) Are there any better ways to plot the 2D correlation matrix for correlations>= 0.85Please let me know. -- View this message in context: http://r.789695.n4.nabble.com/Please-help-Converting-a-2D-matrix-to-3-columns-for-graphical-representation-tp3243688p3243688.html Sent from the R help mailing list archive at Nabble.com.
Tal Galili
2011-Jan-28 08:20 UTC
[R] Please help -- Converting a 2D matrix to 3 columns for graphical representation
There you go: rdata = replicate(100, rnorm(15)) #construct a 2D matrix c1 = cor(rdata) require(reshape) m_c1 <- melt(as.matrix(c1)) head(m_c1) Cheers, Tal ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Fri, Jan 28, 2011 at 6:13 AM, kparamas <kparamas@asu.edu> wrote:> rdata = replicate(100, rnorm(15)) #construct a 2D matrix > c1 = cor(rdata) >[[alternative HTML version deleted]]
Reasonably Related Threads
- using SNOW and clusterApplyLB to run jobs parallel
- ignore NA column in a DF (for calculation) without removing them
- SEM : Warning : Could not compute QR decomposition of Hessian
- simulate data based on partial correlation matrix
- Characteristic Path length calculation