Create

rCharts uses a formula interface to specify plots, just like the lattice package. Here are a few examples you can try out in your R console.

Note

Every example comes with an edit button that allows you to experiment with the code online. The online playground was built using OpenCPU

First let us load the rCharts package

library(rCharts)

Polycharts

r1 <- rPlot(mpg ~ wt, data = mtcars, type = 'point')
r1
Edit

Standalone

NVD3

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
Edit

Standalone

View Interactive

Morris

data(economics, package = "ggplot2")
econ <- transform(economics, date = as.character(date))
m1 <- mPlot(x = "date", y = c("psavert", "uempmed"), type = "Line", data = econ)
m1$set(pointSize = 0, lineWidth = 1)
m1
Edit

Standalone

Highcharts

h1 <- hPlot(x = "Wr.Hnd", y = "NW.Hnd",
  data = MASS::survey,
  type = c("line", "bubble", "scatter"),
  group = "Clap",
  size = "Age"
)
h1
Edit

Standalone

Rickshaw

usp = reshape2::melt(USPersonalExpenditure)
usp$Var2 <- as.numeric(as.POSIXct(paste0(usp$Var2, "-01-01")))
p4 <- Rickshaw$new()
p4$layer(value ~ Var2, group = "Var1", data = usp, type = "area")
p4$set(slider = TRUE)
p4

Standalone

Edit

xCharts

require(reshape2)
uspexp <- melt(USPersonalExpenditure)
names(uspexp)[1:2] = c('category', 'year')
x1 <- xPlot(value ~ year, group = 'category', data = uspexp,
  type = 'line-dotted')
x1

Standalone

Edit