use*_*472 4 r r-markdown nvd3.js rcharts
当我将一个R Markdown文档编织成html时,我遇到了使用'nPlot'渲染rChart的问题.
我按照这个问题中讨论的解决方案,但没有成功.
这是我的.Rmd代码
```{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
Run Code Online (Sandbox Code Playgroud)
这是该代码中html文档的链接.我在RStudio中制作并创作了这个,渲染无法在本地机器上显示,也无法在上传到Dropbox时显示.
当我在控制台中运行以下代码并另存为html时,我得到了这个渲染.
library(rCharts)
m2 <- nPlot(speed ~ dist, data = cars, type = "scatterChart")
m2$save('test3.html', standalone = TRUE)
Run Code Online (Sandbox Code Playgroud)
得到它了.
看到这个答案:拉姆纳特躺了下来
(胸部肿胀的满足感快速缩小,实现时我们只是看着过时的教程/演练......)
最后一行应该是
n1$print('iframesrc', cdn =TRUE, include_assets=TRUE)
Run Code Online (Sandbox Code Playgroud)
我认为大多数教程都使用旧版本或其他东西.但上面对我来说很有用,所以试一试.
然后编织,然后你很高兴去.还要确保你的rCharts库是最新的
install_github("ramnathv/rCharts")
Run Code Online (Sandbox Code Playgroud)