Data Visualization with R
The ggplot2
Library
ggplot2
LibraryOne of the most proficient libraries for data visualization with R is ggplot2. In fact, the library is the reason why I prefer using R for more advanced visualizations that go beyond the capabilities of the Databricks standard features.
The Grammar of Graphics
ggplot2 is based on the grammar of graphics. If you have never heard of ggplot2 or the grammar of graphics, read this fantastic introduction by Bradley Boehmke from the University of Cincinnati. He is also the author of the book Data Wrangling with R:
The grammar [..] suggests the high-level aspects of a plot that can be changed, giving you a framework to think about graphics, and hopefully shortening the distance from mind to paper [3].
In brief, the grammar tells us that a graphic maps the data to the aesthetic attributes (colour, shape, size) of geometric objects (points, lines, bars). The plot may also include statistical transformations of the data and information about the plot’s coordinate system. Facetting can be used to plot for different subsets of the data. The combination of these independent components are what make up a graphic [3].
Cheat Sheet
On the GitHub account of the popular RStudio, a development environment for the R language, you find a useful 2-page cheat sheet for the most important commands in ggplot2:
If you want to dive deeper, I recommend the book ggplot2: Elegant Graphics for Data Analysis. for which the 3rd edition soon to be published by Springer is available online:
References
[1] Boehmke, Ph D. Data Wrangling with R. 1st ed. 2016, Springer International Publishing : Imprint: Springer, 2016.
[2] Wickham, Hadley, and Garrett Grolemund. R for Data Science: Import, Tidy, Transform, Visualize, and Model Data. First edition, O’Reilly, 2016. Online: https://r4ds.had.co.nz/index.html
[3] Wickham, Hadley. Ggplot2. Springer Science+Business Media, LLC, 2016. Preprint of 3rd edition online: https://ggplot2-book.org/
Last updated
Was this helpful?