Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - riverplot formatting nodes

I have been fiddling around with the riverplot package and have produced some very attractive and illustrative results. I am now trying to produce a somewhat more complicated plot and some of the results that I am getting are a little unexpected. I have a minimal example which illustrates the problem. Here is the plot:

riverplot example with anomalous node widths

My problem lies with the widths of nodes B, C and E. The idea with these plots (as I understand it) is that the width of the node is determined by the total width of the rivers flowing into/out of the nodes. Now for nodes A, D and F this is certainly the case. But the other three nodes are either wider/narrower than their attached rivers. It's not a big deal, but it does detract from the impact of the plot.

Either I have made a mistake in constructing my data or I am misunderstanding the way that the package works internally. In either case, I would really appreciate any feedback!

Best regards, Andrew.

Here is the code. The data structure was dumped with dput().

library(riverplot)

RP <- structure(list(
  nodes = structure(
    list(
      ID = structure(c(1L, 3L, 5L, 2L, 4L, 6L), .Label = c("A", "D", "B", "E", "C", "F"), class = "factor"),
      x = c(1L, 1L, 1L, 2L, 2L, 2L)
    ), .Names = c("ID", "x"), row.names = c("A", "B", "C", "D", "E", "F"), class = "data.frame"), 
  edges = structure(
    list(
      N1 = c("A", "A", "A", "B", "B", "B", "C", "C", "C"),
      N2 = c("D", "E", "F", "D", "E", "F", "D", "E", "F"),
      Value = c(0.265, 0.372, 0.572, 0.908, 0.201, 0.898, 0.944, 0.660, 0.629)
    ), .Names = c("N1", "N2", "Value"), row.names = c(NA, -9L), class = "data.frame")),
  .Names = c("nodes", "edges"), class = c("list", "riverplot"))

plot(RP, plot_area = 0.85)
like image 866
datawookie Avatar asked Mar 25 '26 13:03

datawookie


1 Answers

As it turns out, there was a minor bug in the riverplot package. The package author has fixed it and the new version (v0.3) will work fine for this case.

like image 102
datawookie Avatar answered Mar 27 '26 05:03

datawookie