Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnathv/08688a0e79cd01602afa to your computer and use it in GitHub Desktop.
Save ramnathv/08688a0e79cd01602afa to your computer and use it in GitHub Desktop.
HighCharts Example

This is a short demo of how to plot multiple series using hPlot in rCharts. The trick is to melt the data to long form and then use the group argument to specify the series name.

# create dummy data frame
dat <- data.frame(
x = rnorm(100),
y1 = rnorm(100),
y2 = rnorm(100)
)
# melt the data to long form
library(reshape2)
datm = melt(dat, id = 'x',
variable.name = 'g',
value.name = 'y'
)
library(rCharts)
hPlot(y ~ x,
data = datm,
group = 'g',
type = 'scatter'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment