When I run this RMarkdown code:
---
title: "test"
output: html_document
---
```{r cache=FALSE}
library(rCharts)
library(knitr)
opts_chunk$set(comment = NA, results = "asis", comment = NA, tidy = F)
hair_eye = as.data.frame(HairEyeColor)
p2 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == "Female"), type = 'multiBarChart')
p2$chart(color = c('brown', 'blue', '#594c26', 'green'))
p2$show('inline', include_assets = TRUE, cdn = TRUE)
```
I get this: http://rpubs.com/rajesh06/test_Rmd
I also tried the "self-contined: no" option by changing to this:
output:
html_document:
self-contained: no
but that did not seem to help.
Any ideas?
In my work I have a Mac and $show() works properly. I tried some of the code at my home's PC and for some reason $show() did not work. However, there is an easy way around to solve this issue using the $save() function:
---
title: "test"
output: html_document
---
```{r cache=FALSE}
library(rCharts)
library(knitr)
opts_chunk$set(comment = NA, results = "asis", comment = NA, tidy = F)
hair_eye = as.data.frame(HairEyeColor)
p2 <- nPlot(Freq ~ Hair, group = 'Eye', data = subset(hair_eye, Sex == "Female"), type = 'multiBarChart')
p2$chart(color = c('brown', 'blue', '#594c26', 'green'))
p2$save("p2.html", standalone = TRUE)
```
<iframe src="p2.html" align="center" width="900" height="600" frameBorder="0"></iframe>
You can find the discussion I got this solution from here: https://github.com/ramnathv/rCharts/issues/373
I recommend you to use the $save() function as it actually allows adding controls to the rCharts in standalone html which $show() does not.