R - riverplot formatting nodes

I've played around with the riverplot package and produced some very attractive and revealing results. I'm currently trying to create a slightly more complex plot, and some of the results I get are a little unexpected. I have a minimal example that illustrates the problem. Here's the plot:

riverplot example with anomalous node widths

My problem is the widths of the nodes B, C and E. The idea with these plots (as far as I understand) is that the width of a 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 wider / narrower than their adjacent rivers. It doesn't matter, but it distracts from the influence of the plot.

Either I made a mistake in plotting my data, or I misunderstand how the package works internally. Anyway, I would really appreciate any feedback!

Regards, Andrew.

Here is the code. The data structure has been dumped using 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)

      

+3


source to share


1 answer


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



+1


source







All Articles