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 data comes 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

06a-intro-to-ggplot.pdf

06b-more-dplyr.pdf

๐ŸŽฏ 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"

๐Ÿ“š Reading