This project has moved and is read-only. For the latest updates, please go here.

Creating a digram using RCharts

Aug 25, 2014 at 8:41 AM

I have written as script on R and save it in a file which goes like this

library(igraph)
library(rCharts)

g<-graph.tree(40,children=4)

E(g)$weight=1

edgelist<-get.data.frame(g)
colnames(edgelist)<-c("source","target","value")

edgelist$source<-as.character(edgelist$source)
edgelist$target<-as.character(edgelist$target)

sankeyPlot<-rCharts$new()

sankeyPlot$setLib("K:/R Script File/rCharts_d3_sankey-gh-pages/libraries/widgets/d3_sankey")
sankeyPlot$setTemplate("K:/R Script File/rCharts_d3_sankey-gh-pages/libraries/widgets/d3_sankey/layouts/chart.html")

sankeyPlot$set(
data=edgelist,nodeWidth=15,nodePadding=10,layout=32,width=960,height=500)

sankeyPlot$print(chartId="sankey1")

But when I run this code via calling Source R Code from file.It does not show the Sankey Chart instead it shows the javascript code in the console.After that when I write sankeyPlot on the console then the browser will open but show nothing..Please help me what Iam doing wrong and how can it be solve..Thanks in Advance.
Sep 4, 2014 at 8:50 AM
library(igraph)
library(rCharts)

g<-graph.tree(40,children=4)

E(g)$weight=1

edgelist<-get.data.frame(g)
colnames(edgelist)<-c("source","target","value")

edgelist$source<-as.character(edgelist$source)
edgelist$target<-as.character(edgelist$target)

sankeyPlot<-rCharts$new()

sankeyPlot$setLib('http://timelyportfolio.github.io/rCharts_d3_sankey') #Changing the Library Path solved the problem
sankeyPlot$setTemplate(script = 'K:/R Script File/Sankey With RCharts/rCharts_d3_sankey-gh-pages/libraries/widgets/d3_sankey/layouts/chart.html')

sankeyPlot$set(
data=edgelist,nodeWidth=15,nodePadding=10,layout=32,width=960,height=500)

sankeyPlot

I have the library path and now it point directly to the github server and now the charts are working fine,but I still working on the previous error as if I have to set path locally.So Iam working on it and hope to solve it (God Willing).