[R] network

Gabor Csardi csardi at rmki.kfki.hu
Fri Jul 11 15:33:17 CEST 2008

I'm sure this is possible with 'network', but i'm not very familiar 
with that package. In case you don't get an answer on how 
to do it with network, here is how to do it with the 'igraph' package:

M <- matrix(runif(100)*2-1, 10, 10)
M[ lower.tri(M, diag=TRUE) ] <- 0

M[ abs(M) < 0.5] <- 0

g <- graph.adjacency(M, weighted=TRUE, mode="upper")
E(g)$color <- "green"
E(g)[ weight<0 ]$color <- "red"

g$layout <- layout.fruchterman.reingold

Please tell me if something is not clear,

On Fri, Jul 11, 2008 at 02:04:54PM +0100, Dry, Jonathan R wrote:
> Hello
> I am a relatively new user of R and am struggling to use the 'network' package.  I have a correlation matrix (produced using 'cor'), and want to draw a network where each item showing correlation above a threshold (say 0.5) is joined by a green line, and each item showing correlation below a threshold (say -0.5) is joined by a red line.  Does anyone have any hints of how to correctly use functions within the 'network' package to achieve this?
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Csardi Gabor <csardi at rmki.kfki.hu>    UNIL DGM

More information about the R-help mailing list