[R] Ordering in Sankey diagram using R and googleVis
Angela
angelat416 at yahoo.com
Wed Jul 22 19:15:39 CEST 2015
Hello,
I am trying to figure out if there is a way to order the left side of a Sankey diagram from most frequent to least frequent. I am using R version 3.2.1 and using googleVis version 0.5.9 for the Sankey. I've tried sorting, but that does not work. Is there anyway to force it to arrange the left ("before") side in decreasing frequency? Something I am missing? Does not have to be using googleVis. Thank you!
-Angela
Example of the data I have, in a csv file:
before after
A B
A B
A B
A C
A A
A A
A B
D E
F B
F B
F F
G H
G A
I reformat the data in R so it looks like this:
before after count
A B 4
A C 1
A A 2
D E 1
F B 2
F F 1
G H 1
G A 1
Then plot using this:
plot( gvisSankey (data, from="before", to="after", weight="freq", options=list(width=600, height=800,
sankey="{iterations: 2}")))
More information about the R-help
mailing list