Interactive charts with rCharts

[This article was first published on Educate-R - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I have a few upcoming presentations as a part of job interviews. To prepare for these interviews, I’m attempting to make my figures a bit more interactive within my presentations. The aim is to be able to limit any large cumbersome tables I would need to include in my presentations and replace them with interactive plots that can look up values, zoom in, etc.

I initially explored both plot.ly and rCharts, but ended up using rCharts as I found I was more easily able to put it directly into my presentation. It may be possible with plot.ly but I did not want to put in the time to figure it out. I could only find a way to link to the website for the interactive version.

Using highcharts.js that is integrated into rCharts I was able to create the following interactive figure that explores the convergence rate of a portion of my dissertation.

library(rCharts)

h1 <- hPlot(x = "GenSerCor", y = "percent", group = "FitSerCor", data = converge)
h1$yAxis(title = list(text = "Convergence Rate"), min = 0, max = 100, tickInterval = 10)
h1$xAxis(title = list(text = "Generated Serial Correlation Structure"),
         categories = c("Ind", "AR1", "MA1", "MA2", "ARMA"))
h1$legend(verticalAlign = "top", align = "right", layout = "vertical", title = list(text = "Fitted SC"))
h1$plotOptions(series = list(lineWidth = 4))
h1$print('chart1', include_assets = TRUE, cdn = TRUE)

I edited the javascript manually to get some of the effects that I was looking for. For example, the differing line styles and adding the ability to zoom. It is possible to add this directly through rCharts, however I found it much more cumbersome compared to editing the effects I wanted manually. I find the rCharts framework is nice to give the user the barebones needed to produce an interactive plot that can be put into an HTML slideshow. Once getting the general structure, it is easy to look at the documentation for the javascript library and customize the plot yourself. I personally use slidy for that aspect and that is where I will use plots like this in the future. Creating these plots has also helped me to start learning some basics of Javascript which has been on my wish list for the last year or so.

To leave a comment for the author, please follow the link and comment on their blog: Educate-R - R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)