Interactive charts in the browser with the rCharts package

learning from https://gist.github.com/ramnathv/8118442

require(knitr)
opts_chunk$set(results = "asis", comment = NA, tidy = F)
options(RCHART_WIDTH = 600, RCHART_HEIGHT = 400)
require(rCharts)
n1 <- nPlot(mpg ~ wt, data = mtcars, type = 'scatterChart')
n1$show('iframesrc', cdn = TRUE)
n1$show('inline', include_assets = TRUE, cdn = TRUE)

library(rCharts)
h1 <- hPlot(mpg ~ wt, data = mtcars, type = "scatter")
h1$show('iframesrc', cdn = TRUE)
h1$show('inline', include_assets = TRUE, cdn = TRUE)

hair_eye_male <- subset(as.data.frame(HairEyeColor), Sex == "Male")
n2 <- nPlot(Freq ~ Hair, group = "Eye", data = hair_eye_male, type = "multiBarChart")
n2$show('iframesrc', cdn = TRUE)
n2$show('inline', include_assets = TRUE, cdn = TRUE)