index.Rpres
Embedding rCharts
========================================================
author: Ramnath Vaidyanathan
date: 24-Dec-2013
Outline
=======
This is a short demo on how to embed visualizations created using [rCharts](http://rcharts.io) in an RStudio Presentation (called RPres).
Make sure to set the chunk options `results = "asis"` and `comment = NA` so that the html output is rendered asis by knitr. Set `cache = F` on this setup chunk to ensure that this chunk is always evaluated.
```{r setup, cache = F}
require(knitr)
opts_chunk$set(results = "asis", comment = NA, tidy = F)
```
Highcharts
==========
```{r create, tidy = F}
library(rCharts)
h1 <- hPlot(Pulse ~ Height, data = MASS::survey,
type = "scatter", group = "Exer"
)
```
Option 1: IFrame (Inline)
========================================================
```{r iframesrc}
h1$show('iframesrc', cdn = TRUE)
```
Option 2: Inline
=================
```{r inline}
h1$show('inline', include_assets = TRUE, cdn = TRUE)
```
Polycharts
===========
```{r}
hair_eye = as.data.frame(HairEyeColor)
p2 <- rPlot(Freq ~ Hair, color = 'Eye',
data = hair_eye,
type = 'bar'
)
p2$facet(var = 'Eye', type = 'wrap', rows = 2)
```
IFrame Inline
=============
```{r}
p2$show('iframesrc', cdn = TRUE)
```
Inline
=============
```{r}
# NOTE HOW CSS INTERFERES WITH CHART
p2$show('inline', include_assets = TRUE, cdn = TRUE)
```
NVD3
====
```{r}
hair_eye = as.data.frame(HairEyeColor)
p3 <- nPlot(Freq ~ Hair, group = 'Eye',
data = subset(hair_eye, Sex == "Female"),
type = 'multiBarChart'
)
p3$chart(color = c('brown', 'blue', '#594c26', 'green'))
```
IFrame Inline
=============
```{r}
p3$show('iframesrc', cdn = TRUE)
```
Inline
=======
```{r}
p3$show('inline', include_assets = TRUE, cdn = TRUE)
```