你如何使用knitHTML发布rCharts

时间:2015-10-22 18:28:18

标签: r knitr rcharts

我正在尝试使用knitrHTML发布rCharts,我不断收到此错误:

Quitting from lines 11-43 (ddd.Rmd) 
Error in file(con, "w") : cannot open the connection
Calls: <Anonymous> ... <Anonymous> -> <Anonymous> -> <Anonymous> -> writeLines -> file

Execution halted

这是我在减价时的代码:

rPlot(cpubusy ~ datetime, color = 'machine', type = 'point', data = server)

我怎么解决这个问题?我错过了什么?

1 个答案:

答案 0 :(得分:3)

请参阅 - Ramnath回答。

基本上要添加rCharts并在knitr内呈现,您需要使用print方法和include_assets = TRUE。这将告诉knitr添加JS所需的CSSrCharts资产。

还要确保你的块有{r results = 'asis', comment = NA}

```{r results = 'asis', comment = NA}
   p <- rPlot(speed ~ dist, data = cars, type = 'point')
   p$print('chart', include_assets = TRUE)
```