knitr rchart 数据表 dtable 不渲染

问题描述 投票:0回答:1

我读过:

这样做,我仍然遇到问题。

我安装 rCharts 的目的是:

安装rCharts

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

如果我有一个.Rmd喜欢

测试.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$show
tab2$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 确实会渲染!所以我不知道我是否错过了一个参数或者这是一个错误。

r knitr rcharts
1个回答
1
投票

从打印功能中删除 cdn 以使用本地 JS 和 CSS。

tab2$print('chart2', include_assets= TRUE)
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.