top of page

A brief introduction to interactive graphs in R


Hi there

I'm really glad that I have chance to share something new with you guys.

Everything just started with a simple question.

"Hamze, do you know how to create such a graph like this?” a friend of mine asked me when she was showing me an interactive graph in her computer and I just said NO.

I guess you never look for it until you need it. So I searched.

It seems to me there are couples of ways to generate an interactive graph in r. The first approach is to use different packages like "rCharts" or "RMaps" or alternativly use API's provided by websites like plotly.

If you know how to plot with lattice package probably it's not gonna take you long time to learn working with rCharts. It uses the same grammer style and it's easy to understand. rCharts uses the following JavaScript packages :Polycharts, Morris, NVD3, XCharts, Highcharts and Rickshaw. Basically, all you need to do is just calling the library, calling the function corresponding to your favorite JavaScript package and print it. That's all. It then generates a HTML file following with a JavaScript file which makes you able to embded you graph into RMarkdown, Shainy apps, or even your blog. Don't ask me why ???? I would have put one here if I could: D (Wix doesn't let me to do so).

Here is a simple example :

require(rCharts)

r1 <- rPlot(mpg ~ wt | am + vs, data = mtcars, type = "point", color = "gear")

r1

Featured Posts
Recent Posts
Archive
Search By Tags
bottom of page