2015-01-23 6 views
4

R Markdown 문서를 html로 편직 할 때 'nPlot'으로 만든 rChart를 렌더링 할 때 문제가 있습니다.R Markdown의 rChart가 렌더링되지 않습니다

이 내용은이 question에서 논의 된 솔루션을 따르지만 성공하지 못했습니다.

여기 여기 내 .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 

입니다 코드에서 HTML 문서에 link입니다. RStudio에서 이것을 제작하고 저술했는데 Dropbox에 업로드 할 때 렌더링이 내 로컬 컴퓨터에 나타나지 않습니다.

콘솔에서 다음 코드를 실행하여 html로 저장하면 this rendering이됩니다.

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

답변

5

GOT IT. Ramnath layin' it down

(가슴 붓기/빨리 우리가 오래된 자습서보고 있었다 실현에 수축 만족감을 연습 ...) 마지막 줄이 있어야 할

:

이 대답을 참조
n1$print('iframesrc', cdn =TRUE, include_assets=TRUE) 

대부분의 자습서는 이전 버전이나 다른 것을 사용하고 있다고 생각합니다. 하지만 위의 작품은 나를 위해, 그래서 그것을 줘.

다음 뜨개질을하면 좋을 것입니다. 또한 당신이 라이브러리 내가이 실제로 작동하도록 많은 오래된 튜토리얼 오랫동안 고생 때문에 나는 여기에 업데이트 된 대답을 추가 해요 날짜

install_github("ramnathv/rCharts") 
+1

나는 그 제안 중 하나가 성공하지 못했을 까봐 두려워. – user3334472

+0

어 ... 미안. 네가하는 똑같은 문제가있어.위의 코드는 모든 예제/walkthrough와 동일하게 보이지만, 파고들 수 있습니다.하지만 그냥 비어 있습니다. 내가 중요하다면 나는 크롬을 사용하는 윈도우 박스 위에있다. – colemand77

+0

@ user3334472, 위 참조. 우리는 만료 된 자습서를보고있었습니다. – colemand77

2

에 달려있다 rCharts 야합니다. 또한, 현재의 대답은 나를 위해 작동하지 않았다. 이 작업을 수행

...

```{r set-options, echo=FALSE, cache=FALSE} 
options(RCHART_WIDTH = 1000, RCHART_HEIGHT = 400) 
``` 

```{r, echo=FALSE, cache=T, results='asis', comment=NA} 
p1 <- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type = 'scatterChart') 
p1$print('chart1', include_assets=T) 
``` 

```{r, echo=FALSE, cache=T, results='asis', comment=NA} 
hair_eye = as.data.frame(HairEyeColor) 
p2 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == "Female"), type = 'multiBarChart') 
p2$print('chart2', include_assets=T) 
``` 

참고 : 나는 차트 코드, 옵션이 상단에 차단하지와 청크에 results='asis'comment=NA을 설정하는 데 필요한

  • .
  • cdn=T은 나를 위해 오류를 발생 시켰습니다. R이 공개 파일을 찾고있어 찾을 수 없습니다.
  • 차트에 각각 고유 한 이름이 필요하거나 서로 오버라이드 또는 차트로 표시됩니다.
  • 내가 R 3.1.2, rCharts_0.4.5, 당신은 HTML로 rChart 플롯을 절약 할 수 있습니다
0

rmarkdown_0.7이 옵션 덩어리

  • 의 높이와 차트의 폭을 업데이트 할 수 있습니다 그런 다음 shiny::includeHTML("plot.html")과 함께 RMarkdown 문서에 포함하십시오. 이것은 나를 위해 일했다.

  • 관련 문제