Summary
In this chapter, we studied one of the main graphic packages in marketing. The ggplot2 library is capable of so much that it was even translated into other languages, such as Python.
We began the chapter discussing the interesting theory of the grammar of graphics, using an analogy of textual grammatical elements and looking at the elements needed to construct and plot a good visualization. ggplot2 was built on top of that concept, enabling analysts to code a graphic by layers, adding one piece at a time. We then introduced a template of questions to help organize our thinking when creating code: (1) start with a dataset, (2) choose a geometry, (3) provide axes and aesthetics, and (4) add a title, labels, statistics, and themes.
After familiarizing ourselves with the syntax, we studied the code for the most commonly used types of graphics, such as histograms, boxplots, scatterplots, bar plots, and line plots. Then, we introduced smooth geometry, which helps us to create...