Data Visualization with R

This post is part of Data Science with R.

Producing clean graphs in R can be a challenging task, but when done right, graphs can be appealing, informative, and of considerable value. Traditionally, R was used for producing graphs in academic article, but it’s now so versatile that you can produce stunning data visualizations in just few lines of codes:

What we learnt from the video is that beautiful visualizations can be made easily with

  1. leaflet for maps
  2. quantmod for easy stock data visualization
  3. dygraph for time series data
  4. corrplot for correlation plots: example here
  5. ggvis for interactive graphics using ggplot-like syntax

Having said that, these are my favourite visualization frameworks because they are so versatile:

  1. plotly for interactive graphs: examples here.
  2. googleVis
  3. shiny for dashboards: example here

But how to select which type of chart to use? The following diagram would help (or this whitepaper from Tableau).

a7c23a32-aa09-4c68-951d-f10a51a6a134-original

PS: Some people say pie charts are no good, but sometimes it can be useful.

There are, by the way, 7 different types of data stories:

  1. Narrate Change over time
  2. Start big and drill down
  3. Start small and zoom out
  4. Highlight contrasts
  5. Explore the intersection
  6. Dissect the factors
  7. Profile the outliers

Meanwhile, Tableau has some whitepapers related to producing visualizations with R:

When it’s precision over storytelling, we may need to go back old-school: ggplot2! (here’s a cheatsheet)

Here are some ggplot2 examples:

  1. High density scatter plots

basic_density

2. Pie charts

coord_polar-13

There are also ggplot2 extensions: http://www.ggplot2-exts.org/ to create more interesting graphs, for example:

 


Finally, some use cases/gallery:

  1. http://www.r-graph-gallery.com/
  2. Flowing Data’s Best Data Visualization Projects of 2016
  3. http://jkunst.com/r/pokemon-visualize-em-all/
  4. FBI’s aerial surveillance
Advertisements

One Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s