Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So, the problem is creating a line plot that represents the interaction.</p> <p>To do this, you need to format your data in the appropriate form. You want to plot segments, and for this you need the co-ordinates of each segment in a single row in your data frame:</p> <pre><code>interaction &lt;- merge(propdata, relation, by.x="name", by.y="name1") interaction &lt;- cbind(interaction, merge(propdata, relation, by.x="name", by.y="name2")[, c("X", "Y")]) names(interaction)[8:9] &lt;- c("Xend", "Yend") interaction name diameter X Y colr name2 score Xend Yend 1 A 4.3 1 1 10 B 1.1 2 3 2 A 4.3 1 1 10 C 2.2 3 3 3 A 4.3 1 1 10 D 5.4 3 3 4 B 8.3 2 3 20 C 3.1 4 4 5 B 8.3 2 3 20 D 2.0 4 4 </code></pre> <p>Now we run into another problem. In <code>ggplot2</code>, you can only have a single size scale. Since you have a size argument for both the point and line, that really represents two things, this can't be done without a workaround.</p> <p>Thus the workaround is to manually draw the circles using <code>geom_polygon</code>.</p> <p>Construct the data frame with circles:</p> <pre><code>circle &lt;- function(x, y, d, color, scale=1){ d &lt;- d * scale angle &lt;- seq(-pi, pi, length = 50) data.frame( x = x + d/2*sin(angle), y = y + d/2*cos(angle), color=color) } circles &lt;- ddply(propdata, .(name), function(x)with(x, circle(X, Y, diameter, colr, scale=0.2))) </code></pre> <p>Finally, create the plot:</p> <pre><code>ggplot() + geom_polygon(data=circles, aes(group=name, x=x, y=y, fill=color)) + geom_text(data=propdata, aes(x=X, y=Y, label=name), hjust=0, vjust=0) + geom_segment(data=interaction, aes(x=X, y=Y, xend=Xend, yend=Yend, size=score)) + scale_size("Inter", to=c(0, 5)) + coord_equal() </code></pre> <p><img src="https://i.stack.imgur.com/aixSm.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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