A Grammar of Graphics with ggplot2

Philippe De Brouwer · 2020

This chapter provides tactical examples that learn how to use ggplot2 in practice. To explore ggplot2, one can use the dataset mtcars from the library datasets. It is usually loaded as the start of R. Generally, we can expect more than 32 rows in a dataset and soon plots will be so busy that it is not possible to spot any trend or pattern. We can think of some tools to solve this problem in base R: use a plot character that is small (like pch = 1, 3, or 5) or use boxplots. However, ggplot2 has a larger set of tools to tackle this situation. The chapter also shows an example on a dataset – the dataset “diamonds.” This dataset is provided by the package ggplot2 and is ideally suited to show the excellent capabilities of ggplot2.

Read the paper · More papers on PaperTik