Skip to content

Instantly share code, notes, and snippets.

@Deleetdk
Created February 15, 2023 05:38
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 Deleetdk/21f4571b79ad9331776012fa35ae0af0 to your computer and use it in GitHub Desktop.
Save Deleetdk/21f4571b79ad9331776012fa35ae0af0 to your computer and use it in GitHub Desktop.
interracial rape stats
library(googlesheets4)
library(kirkegaard)
theme_set(theme_bw())
#read data
d = read_sheet("https://docs.google.com/spreadsheets/d/1cPApEVEPNj4DXTB7LN7hd7B6WxYQiottbfHFt72tCzE/edit#gid=0")
#transform to long form for plotting
d_long = d %>%
pivot_longer(
cols = -Year,
names_to = "type",
values_to = "proportion"
) %>% mutate(
perp = str_match(type, "\\w+\\b")[, 1],
victim = str_match(type, "\\w+$")[, 1],
)
d_long %>%
select(-type) %>%
ggplot(aes(Year, proportion, color = perp)) +
geom_line() +
facet_wrap("victim", labeller = "label_both")
GG_save("interracial rape stats.png")
#stats
describe2(d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment