knitr r chart datatable table不呈现

时间:2015-02-21 21:02:35

标签: r jquery-datatables knitr rcharts

首先,请原谅我的英语,第二,我读过:

这样做,我仍然有问题

我安装了rCharts

安装rCharts

install.packages("devtools")
library("devtools")
install_github("ramnathv/rCharts")
library("knitr")

如果我有.Rmd喜欢

test.Rmd

```{r ,results='asis', comment= NA,  echo=FALSE}
library(rCharts)
tab2 <-  dTable(as.data.frame(summary(cars)))
# tab2$show('inline', include_assets= TRUE, cdn= TRUE)
tab2$print('chart2', include_assets= TRUE, cdn= TRUE)
```

当我跑

knit2html(input = 'test.Rmd', output = 'test.html')

test.html不呈现(我尝试使用tab2$showtab2$print)。但是如果我用编辑器打开test.html,可以阅读以下内容

<p><link rel='stylesheet' href=//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css></p>
<script type='text/javascript' src=//code.jquery.com/jquery-1.10.2.min.js></script>
<script type='text/javascript' src=//ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js></script> 

这似乎不正确,因为每个http:src都没有href,因此我将http:置于更改为

的位置
<p><link rel='stylesheet' href=http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css></p>
<script type='text/javascript' src=http://code.jquery.com/jquery-1.10.2.min.js></script>
<script type='text/javascript' src=http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js></script> 

在此之前,test.html确实渲染!!所以我不知道我是否错过参数或者这是一个错误,请帮帮我

1 个答案:

答案 0 :(得分:1)

从print函数中删除cdn以使用本地JS和CSS。

tab2$print('chart2', include_assets= TRUE)