Skip to content

Instantly share code, notes, and snippets.

@robwschlegel
Created July 3, 2017 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robwschlegel/37806e19e0c60b03da80d1c32c0302f4 to your computer and use it in GitHub Desktop.
Save robwschlegel/37806e19e0c60b03da80d1c32c0302f4 to your computer and use it in GitHub Desktop.
# Calculate residuals
green_card_resids <- augment(lm(Number~Year, data = green_card))
green_card_resids <- merge(green_card_resids, party_year, by = "Year")
# Plot them
ggplot(data = green_card_resids, aes(x = Year, y = .resid)) +
geom_col(aes(fill = Party), colour = "black") +
geom_smooth(method = "lm", colour = "black") +
labs(x = NULL, y = "Green Cards Granted") +
scale_fill_manual(values = c("slateblue1", "firebrick1"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment