Why use data in political science?

Readings and class materials for Sunday, August 23, 2026

Readings

Nothing!

Slides

Movies

Class movies

Record your movies here!

All movies

library(tidyverse)
library(ggplot2movies)
library(ggdist)

set.seed(1234)  # Set seed so we get the same sampled rows every time

movies_clean <- movies |>
  select(title, year, rating, Action, Comedy) |>
  filter(!(Action == 1 & Comedy == 1)) |>
  mutate(
    genre = case_when(
      Action == 1 ~ "Action",
      Comedy == 1 ~ "Comedy",
      TRUE ~ "Neither"
    )
  ) |>
  filter(genre != "Neither") |>
  mutate(genre = factor(genre)) |>
  select(-Action, -Comedy) |>
  # Randomly select 100 movies in each genre
  group_by(genre) |>
  sample_n(1000) |>
  ungroup()

movies_clean |>
  group_by(genre) |>
  summarize(avg_rating = mean(rating))
# A tibble: 2 × 2
  genre  avg_rating
  <fct>       <dbl>
1 Action       5.21
2 Comedy       6.00
ggplot(movies_clean, aes(x = rating, y = genre, fill = genre)) +
  geom_dots(layout = "weave", side = "bottom") +
  stat_slabinterval() + 
  guides(color = "none", fill = "none") + 
  labs(x = "IMDB rating", y = NULL)