Part 3: Visualizing data

Visualizing data is a key skill and benefit of data science. After becoming familiar with the foundations of data science and R (in Part 1) and basic programming concepts (in Part 2), this part helps us to apply these insights and skills to visualize data.

This part is structured into four chapters:

  • Chapter 7 motivates why and how we visualize data. Although most people like to look at charts and graphs, it is surprisingly difficult to answer why visualizations are a good idea. And once we begin considering the vast range of options it becomes clear that creating successful visualizations is a rather challenging and difficult task. Thus, the preliminary musings of this chapter may help us to appreciate good visualizations and to inoculate us against some common pitfalls. However, as this chapter contains no code or tools, it can be skimmed or skipped by less reflective readers.

  • Chapter 8 introduces visualizations in base R. As we will see, R provides powerful tools and technologies for creating visualizations. But as the corresponding packages have been evolving over a long time, their functions lack consistency and an underlying systematic framework.

  • Chapter 9 introduces visualizations in ggplot2 (Wickham, Chang, et al., 2023). The R package ggplot2 (Wickham, Chang, et al., 2023) implements a grammar of graphics (based on Wilkinson, 2005) and thus provides a more uniform framework for creating visualizations in R.

  • Chapter 10 introduces using colors in R. Based on some reflections on the elusive and interactive nature of color, we will introduce common color representations (by their names, RGB values, or HEX values), and explore some packages and tools for defining, modifying, and using color palettes in R.

Actually, jumping straight from the basics to visualizations is a bit unusual. In most practical contexts, creating charts and graphs involves some preliminary steps of data wrangling (which we will introduce in Part 4). But as visualizations is a great way to explore data, we use some simple data structures and some tables that others have provided to unleash our creative spirits.