6) Tidyverse part 2
๐ More about dplyr and ggplot
Last week we discussed the basics of dplyr. This week youโll learn about the Grammar of Graphics and its central idea: a graphic involves mapping data to geometric objects and their visual attributes. This is the underlying framework behind the mechanics and core functions available in โggplot2โ for creating simple graphics:
- Begin your graphic specification with
ggplot() - Indicate where the
datacomes from - Establish which variables are going to be mapped into visual attributes:
aes() - Decide what kind of geometric object(s) will be used to display data; e.g.
geom_point() - Optional: do you need to use facets?
- Optional: do you need to explicitly use one or more statistical transformations?
- Optional: do you need to explicitly set a non-default system of coordinates?
- Optional: do you need to explicitly use a non-default theme of graphical elements?
In addition, we introduce so-called pipelines and the use of the pipe operators |> and %>%.
๐ฐ Slides
๐ฏ Objectives
At the end of this week you will be able to:
- Get a first contact with
"ggplot2" - Describe the purpose of the aesthetic mapping function
aes() - Describe the notion of โlayersโ and how to use them for making a graphic using
"ggplot2"