Grammar of Graphics intro

Visualization Best Practices in R

Nick Strayer

Instructor

What is this course?

What you will learn

How to make better visualizations by thinking deeply about the data at hand.

How you will learn it

  • Overviews of different data types
  • Standard visualizations
  • Alternatives
Visualization Best Practices in R

Course layout

Chapter 1: Proportions of a whole

Chapter 2: Point data

Chapter 3: Single distributions

Chapter 4: Multiple(or conditional) distributions

Visualization Best Practices in R

Warning!

 

  • Topics here are not as cut and dry as other programming topics

  • Every rule will have exceptions

  • An emphasis on thinking through each problem is given to help you deal with these cases when you get to them

Visualization Best Practices in R

Tools used

  • R

  • The 'Tidyverse'

  • Ggplot2

Visualization Best Practices in R

Data used

  • Comes from the World Health Organization (WHO)
who_disease
# A tibble: 43,262 x 6
   region countryCode country             disease  year  cases
   <chr>  <chr>       <chr>               <chr>   <int>  <dbl>
 1 EMR    AFG         Afghanistan         measles  2016 638   
 2 EUR    ALB         Albania             measles  2016  17.0 
 3 AFR    DZA         Algeria             measles  2016  41.0 
 4 EUR    AND         Andorra             measles  2016   0   
 5 AFR    AGO         Angola              measles  2016  53.0 
 6 AMR    ATG         Antigua and Barbuda measles  2016   0   
 7 AMR    ARG         Argentina           measles  2016   0   
 8 EUR    ARM         Armenia             measles  2016   2.00
# ... with 43,254 more rows
Visualization Best Practices in R

WHO disease data

# Filter to AMR region 
amr_region <- who_disease %>% 
  filter(region == 'AMR')

# Map x to year and y to cases, color by disease
ggplot(amr_region, aes(x = year, y = cases, color = disease)) + 
  geom_point(alpha = 0.5)
Visualization Best Practices in R

Visualization Best Practices in R

Let's practice!

Visualization Best Practices in R

Preparing Video For Download...