Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created September 29, 2013 20:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/6756488 to your computer and use it in GitHub Desktop.
Save ramnathv/6756488 to your computer and use it in GitHub Desktop.

This shows two examples of how to use rCharts with knitr.

  1. knitr-rcharts1.Rmd: The default behavior of rCharts when embedded in a knitr document is to save the chart as a separate html file and include it in your document as an iframe.
  2. knitr-rcharts2.Rmd: You can force rCharts to print the chart inline, but you also need to include the required js and css assets. The two additional arguments ensure that js/css assets are included, and also rendered from an online CDN so that your html file is standalone.

If you have questions, post as a comment here or on the github repo for rCharts.

# Title
Here is some text
## A header 2
Some more text
## A chart at header 2
```{r scatter, results='asis', comment=NA, message=FALSE}
library(rCharts)
data(cars)
r1 = rPlot(speed ~ dist, data=cars, type='point')
r1
```
# Title
Here is some text
## A header 2
Some more text
## A chart at header 2
```{r scatter, results='asis', comment=NA, message=FALSE}
library(rCharts)
data(cars)
r1 = rPlot(speed ~ dist, data=cars, type='point')
r1$print('chart', include_assets = TRUE, cdn = TRUE)
```
@Btibert3
Copy link

As always, thanks for the prompt response. I followed along with that baseline example per my SO question here:.

From above, I assume its the same issue in that its a lack of assets, but I am way over my skill level at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment