sankey的rCharts情节没有显示

时间:2016-12-30 20:10:04

标签: r rcharts sankey-diagram

我正在使用此页面中的代码http://timelyportfolio.github.io/rCharts_d3_sankey/example_build_network_sankey.html代码如下:

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')

在运行最后一行后,我没有得到任何图像,而是得到这个:  库/部件/ d3_sankey /布局/ chart.html&GT;

然后我添加了以下行:     htmlwidgets :: saveWidget(as.widget(测试), '的test.html') 但是得到了这个错误消息:

  

resolveSizing错误(x,x $ sizingPolicy,standalone = standalone,knitrOptions = knitrOptions):     找不到功能“as.widget”

我实际上是尝试在slidify中使用它,但我在上面提到的源代码中使用的代码在我的PC中无法正常工作,即使是简单的R文件。

0 个答案:

没有答案