Intro to comparing distributions

Buone pratiche di visualizzazione in R

Nick Strayer

Instructor

Why compare distributions?

  • Verify balanced groups
  • For comparison's sake

Buone pratiche di visualizzazione in R

Why not facet histogams?

ggplot(md_speeding, aes(x = speed_over)) + 
  geom_histogram() +
  facet_grid(vehicle_color ~ .)

Buone pratiche di visualizzazione in R

The boxplot

 

Buone pratiche di visualizzazione in R

Boxplot pros

  • Familiar
  • Lots of good summary statistics

Buone pratiche di visualizzazione in R

boxplot cons

  • Show me the data!

Buone pratiche di visualizzazione in R

A simple addition

  • geom_jitter() shows raw points jostled to avoid overlap.
  • Layer under your geom_boxplot().
md_speeding %>% 
  filter(vehicle_color == 'BLUE') %>%
  ggplot(aes(x = gender, y = speed)) +
    # Draw points behind 
    geom_jitter(alpha = 0.3, color = 'steelblue') + 
    # Make transparent
    geom_boxplot(alpha = 0) + 
    labs(title = 'Distribution of speed for blue cars by gender')
Buone pratiche di visualizzazione in R

Buone pratiche di visualizzazione in R

Let's compare some distributions!

Buone pratiche di visualizzazione in R

Preparing Video For Download...