htmlwidgets: Create interactive web charts in R

Posted to Software  |  Tags: ,  |  Nathan Yau

If you don’t want to bother with JavaScript but want to publish interactive graphics for the web or use interaction to explore your data, htmlwidgets might be for you.

HTML widgets work just like R plots except they produce interactive web visualizations. A line or two of R code is all it takes to produce a D3 graphic or Leaflet map. HTML widgets can be used at the R console as well as embedded in R Markdown reports and Shiny web applications.

Use existing widgets that let you visualize with popular JavaScript libraries such as D3 or Leaflet. Or, create your own.


Graphical perception – learn the fundamentals first

Before you dive into the advanced stuff – like just about everything in your life – you have to learn the fundamentals before you know when you can break the rules.

Real Chart Rules to Follow

There are rules—usually for specific chart types meant to be read in a specific way—that you shouldn’t break. When they are, everyone loses. This is that small handful.

This is an American Workday, By Occupation

I simulated a day for employed Americans to see when and where they work.

Life expectancy changes

The data goes back to 1960 and up to the most current estimates for 2009. Each line represents a country.