Hello! This week I also went over the last couple chapters in "Data Visualization with R" by Rob Kabacoff. We skipped chapters 10 and 11 since we went over most of the pertinent information they contained in previous chapters, and went straight to chapters 12 and 13.
Chapter 12 is a fun chapter about interactive graphs. I had to download some additional packages to make them work, such as leaflet.
Chapter 13 provides advice on how to make the graphs most appealing. It goes over labeling, picking colors, and how to best customize your graphs so they are easy and appealing to look at.
Chapter 12: Interactive Graphs
R does not produce these graphs on its own, and makes a connection with JavaScript to make these graphs. Unlike the other graphs in this book that look just as nice on paper as on a screen, interactive graphs need to be viewed on an app or web page.
Leaflet
Leaflet is a JavaScript library for interactive maps. The leaflet package in R is used to create interactive graphs. The book doesn't provide the code used to install leaflet, so I searched "create leaflet graph on r" on Googe. Et voila! The first link gave me the code: install.packages("leaflet"). You can make dot density and choropleth graphs using leaflet. Apparently the package website has detailed tutorial for using leaflet. I clicked on a github link, so I'm not sure if it's the official webpage or not, but I think it is: https://rstudio.github.io/leaflet/
Plotly
Plotly is a commercial and open source product for creating interactive graphs. This package allows you to make plotly graphs in R, and every ggplot2 graph can be made into a plotly graph. This interactive graph type does not require you to download any additional packages outside of what the book provides, so that was nice! You can't see it in the picture, but when I hover my mouse over the points, a label pops up that tells me that points hightway mileage, vehicle class, and engine displacement:
rBokeh
rBokeh is the interface for the Bokeh graph library. This one needed a package downloaded. I decided to make an educated guess and see if install.packages("rbokeh") would download it. It worked! Much like the previous graph, hovering over each element provided information on that element (or elements, if there was multiple at that point).
rCharts
rCharts can create several different types of interactive graphs. The example in the book is an interactive bar graph that allows you to hover over the bars and choose between grouped vs. stacked plots, as well as include or exclude variables. I was not able to view this graph. I tried seeing if I could simply download the package the same way I did the other 2, but it didn't work, and gave me and error about it not working on my version.
Highcharter
The highcharter package also requires a connection to the JavaScript library. I downloaded this package the same way as I did the other packages.
Chapter 13: Advice/Best Practices
This chapter gives a more in depth summary for making your graphs be as readable and good looking as possible.
Labeling
When you are making graphs, everything should be labeled. A quick checklist of things that need labeling on a graph is as follows:
- title
- subtitle
- caption
- axis labels
- legend
- lines and bars
Comments
Post a Comment