R Markdown 中的 rChart 不呈现 [英] rChart in R Markdown doesn't render

查看:45
本文介绍了R Markdown 中的 rChart 不呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将 R Markdown 文档编织为 html 时,我在渲染使用nPlot"制作的 rChart 时遇到问题.

I am having issues rendering an rChart made with 'nPlot' when I knit an R Markdown document to html.

我遵循了这个问题中讨论的解决方案,但没有成功.

I followed the solution discussed in this question, but it was unsuccessful.

这是我的 .Rmd 代码

Here is my .Rmd code

```{r, echo=FALSE}
library(knitr)
```
---
title: "Untitled"
author: "Test"
date: "01/23/2015"
output: html_document
---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE}
plot(cars)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

# Here is an rChart
```{r, echo=FALSE, results='asis', comment=NA}
library(rCharts)
m2 <- nPlot(speed ~ dist, data = cars, type = "scatterChart")
m2$show('iframesrc', cdn = TRUE)
```
That was an rChart

这是从该代码到 html 文档的链接.我在 RStudio 中制作和创作了此内容,但在我的本地计算机和上传到 Dropbox 时都无法显示渲染.

Here is a link to the html document from that code. I produced and authored this in RStudio and the rendering fails to show up both on my local machine and when uploaded to Dropbox.

当我在控制台中运行以下代码并另存为 html 时,我得到 this渲染.

When I run the following code in console and save as an html, I get this rendering.

library(rCharts)
m2 <- nPlot(speed ~ dist, data = cars, type = "scatterChart")
m2$save('test3.html', standalone = TRUE)

推荐答案

明白了.

看到这个答案:Ramnath 把它放下来

(在意识到我们只是在看过时的教程/演练...)后,胸中膨胀的满足感很快就消退了……)

最后一行应该是

n1$print('iframesrc', cdn =TRUE, include_assets=TRUE)

我认为大多数教程都使用旧版本或其他东西.但以上对我有用,所以试一试.

I think most of the tutorials out there are using an old version or something. But the above works for me, so give it a shot.

然后编织,然后你就可以开始了.还要确保您的 rCharts 库是最新的

then knit, then you're good to go. Also make sure you're rCharts library is up to date

install_github("ramnathv/rCharts")

这篇关于R Markdown 中的 rChart 不呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆