Problems reproducing an example Sankey diagram with d3_sankey

I am trying to reproduce a simple example using the rCharts library to plot a sankey graph. I found this example from scratch and tried to reproduce it, however I had some problems.

Firstly, I tried to run this code without anything. Then I found out and realized that I needed d3_sankey on my computer. So, I downloaded it from here and copied it to C:\Users\adomas\Documents\R\win-library\3.0\rCharts\libraries\widgets\d3_sankey .

Then I tried this immutable code again and still got the following error:

Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file '/config.yml': No such file or directory

Since this didn’t help either, I tried changing the paths: sankeyPlot$setLib('libraries/widgets/d3_sankey') sankeyPlot$setTemplate(script = "libraries/widgets/d3_sankey/layouts/chart.html")

to

sankeyPlot$setLib('C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey') sankeyPlot$setTemplate(script = "C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey/layouts/chart.html")

However, this time a blank screen appeared in Viewer, but there is no real Sankey graph, and I received the following in the console: Warning message: In readLines(file, warn = warn, ...) : invalid input found on input connection 'C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey/layouts/chart.html

I tried changing paths, etc., but still something was wrong. And I'm not sure if I need to use sankeyPlot$setTemplate at all. I want to use the Sankey diagram in my brilliant application, but first I want to reproduce it simply in R. Suggestions would help a lot!

Library Versions: rCharts_0.4.2 igraph_0.7.0 Version R: 3.0.2

Editorial: I tried this code on a different system. And everything works there. The versions of the libraries and R are the same, and I copied the same documents and just indicated the full path. I tried this again on my own computer, but still got the same error.

+8
r sankey-diagram rcharts
source share
2 answers

Well, in the end it works as it should.

I just rebooted my system and did it. However, if someone has the same problem, just make sure you provide the direct path where you placed all the necessary files for d3_sankey. So you rather use sankeyPlot$setLib('C:/Users/adomas/Documents/R/win-library/3.0/rCharts/libraries/widgets/d3_sankey')

This is a great type of chart. Good luck

+2
source share

I had the same problems. The solution for me was to update rCharts:

 devtools::install_github("rCharts", "ramnathv") 

Secondly, I did not include the sankeyPlot $ setTemplate () line.

Finally, the path in $ setLib () must be a direct path (as described in the @adomasb solution, or the following line can be used to directly refer to the original github:

 sankeyPlot$setLib('http://timelyportfolio.imtqy.com/rCharts_d3_sankey/libraries/widgets/d3_sankey') 

The disadvantage of this latter approach is that the Internet should always run a script.

+7
source share

All Articles