4.3 Grammar components & ggplot2 (2)

  • See some of the components in Figure 4.1 below (Data: View(mtcars) and ?mtcars).
    • Q: How could we read the code?
    • Q: How would we execute that code to understand it?23
    • Q: How can we best remember what a function/package/argument does?24
    • Q: How do you write down code to make it readable? (line breaks, spaces etc.)
Ggplot2 grammar components

Figure 4.1: Ggplot2 grammar components


  1. Execute it line by line (or from inside to outside)! Same is true for dplyr code!

  2. Either by its name directly.. often by knowing what an abbreviation stands for.