Note that there are some explanatory texts on larger screens.

plurals
  1. POSet color for segments in ggnet
    text
    copied!<p>I hvar the following data set:</p> <pre><code>structure(c(2L, 6L, 2L, 6L, 7L, 7L, 2L, 7L, 6L, 8L, 8L, 4L, 8L, 2L, 9L, 8L, 7L, 6L, 9L, 1L, 9L, 4L, 9L, 3L, 2L, 10L, 9L, 10L, 8L, 10L, 7L, 6L, 10L, 1L, 2L, 12L, 9L, 8L, 12L, 1L, 11L, 10L, 2L, 44L, 79L, 10L, 8L, 47L, 45L, 51L, 9L, 11L, 74L, 75L, 77L, 69L, 75L, 77L, 78L, 2L, 44L, 44L, 46L, 46L, 8L, 6L, 1L, 1L, 6L, 7L, 1L, 4L, 7L, 8L, 8L, 1L, 4L, 8L, 3L, 8L, 8L, 9L, 9L, 9L, 1L, 9L, 5L, 9L, 3L, 9L, 9L, 9L, 10L, 8L, 10L, 7L, 10L, 10L, 1L, 10L, 10L, 9L, 12L, 12L, 1L, 12L, 12L, 12L, 12L, 7L, 7L, 44L, 44L, 44L, 44L, 44L, 44L, 44L, 44L, 44L, 44L, 7L, 7L, 7L, 7L, 44L, 10L, 9L, 42L, 43L, 46L, 46L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, -1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, -1L, 1L, 1L, 1L, -1L, -1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, -1L), .Dim = c(66L, 3L), .Dimnames = list(NULL, c("from", "to", "impact"))) </code></pre> <p>The data set indicates, a connection between from and to with a positive (1) or negative (-1) impact.</p> <p>I would like to plot a network graph with ggnet (or ggplot2) that plot this graph.</p> <p>So far I have done the following steps:</p> <pre><code>library(network) library(ggplot2) library(ggnet) library(grid) net &lt;- network(df2[,c(1,2)], directed = FALSE) ggnet(net, mode = 'kamadakawai', size = 6, alpha = .5, label.nodes=F, segment.alpha = 0.5, color = "black") + theme(legend.position = "none") + theme(plot.margin = unit(c(0.1,0.1,0.1,0.1), "cm")) </code></pre> <p>This lead to this result: <img src="https://i.stack.imgur.com/ObPTc.png" alt="enter image description here"></p> <p>I am wondering how to colorize the edges based on the impact in the dataset (1 = green and -1 = red). I am also wondering why there are so many unconnected nodes...</p> <p>Can someone help me with this?</p> <p>Thanks a lot.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload