Week 4

Lab 3

Monday, Sep 16

GitHub


Advanced visualizations

Tuesday, Sep 17

Learning objectives

  • Organize objects of class gg with package patchwork
  • Build animations with package gganimate and gifski
  • Build interactive plots with package ggiraph
  • Work with new geom functions
  • Understand basics for creating new geom, stat, and theme functions

Materials


Package dplyr

Thursday, Sep 19

Learning objectives

  • Manipulate data frames with the core dplyr functions
  • Understand dplyr function rules
  • Utilize the pipe operator

Materials


Exercise of the week

Create a new stat called stat_outlier() that highlights outliers in a set of bivariate data. Define an outlier as when both values in a data pair have a z-score greater than three in absolute value.

A typical scatter plot with ggplot() and geom_point():

set.seed(09222019)
data_norm <- tibble(x = c(rnorm(95, 100, 5), rnorm(5, 70, 5)), 
                    y = c(rnorm(95, 100, 5), rnorm(5, 70, 5)))

ggplot(data_norm, mapping = aes(x = x, y = y)) +
  geom_point() +
  theme_bw()

An added layer that marks outliers:

ggplot(data_norm, mapping = aes(x = x, y = y)) +
  geom_point() +
  stat_outlier() +
  theme_bw()

Previous
Next