sankey Plot of rCharts doesn't show

388 views Asked by At

I am using the code from this page http://timelyportfolio.github.io/rCharts_d3_sankey/example_build_network_sankey.html The code goes like this:

setwd("F:/Urgent/Compendium/Reserach Presentation/shammun/")
require(igraph)
library(devtools)
library(htmlwidgets)
library(Rcpp)
#install_github('ramnathv/rCharts')
require(rCharts)

sankeyPlot$setLib('C:/Users/shammun/Documents/R/win-   library/3.0/rCharts/libraries/widgets/d3_sankey')
g <- graph.tree(40, children = 4)


E(g)$weight = 1
edgelist <- get.data.frame(g)
colnames(edgelist) <- c("source","target","value")
#make character rather than numeric for proper functioning
edgelist$source <- as.character(edgelist$source)
edgelist$target <- as.character(edgelist$target)
sankeyPlot <- rCharts$new()
sankeyPlot$setLib('libraries/widgets/d3_sankey')
sankeyPlot$setTemplate(script =  "libraries/widgets/d3_sankey/layouts/chart.html")
sankeyPlot$set(
data = edgelist,
nodeWidth = 15,
nodePadding = 10,
layout = 32,
width = 960,
height = 500
)
test = sankeyPlot$print(chartId = 'sankey1')

After running the last line I don't get any image rather get this: libraries/widgets/d3_sankey/layouts/chart.html>

I then added the following line: htmlwidgets::saveWidget(as.widget(test),'test.html') But got this error message then:

Error in resolveSizing(x, x$sizingPolicy, standalone = standalone, knitrOptions = knitrOptions) : could not find function "as.widget"

I was actually trying to use it in slidify but the code I am using from the above mentioned source is not working in my PC even as a simple R file.

0

There are 0 answers