Last active
March 7, 2022 20:07
-
-
Save dwillis/f7e65e253c0255224264ac60994c669d to your computer and use it in GitHub Desktop.
Calculating police shootings' gender percentage with guns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create dataframe of all shootings by gender | |
all_police_shootings_by_gender <- fatal_police_shootings %>% | |
group_by(gender) %>% | |
summarise(count=n()) %>% | |
arrange(desc(count)) | |
# create separate dataframes for each gender | |
all_shootings_men <- all_police_shootings_by_gender %>% | |
filter(gender == 'M') | |
all_shootings_women <- all_police_shootings_by_gender %>% | |
filter(gender == 'F') | |
# create dataframe of all shootings by gender where victim has gun | |
gun_police_shootings_by_gender <- fatal_police_shootings %>% | |
filter(armed_clean == "gun") %>% | |
group_by(gender) %>% | |
summarise(count=n()) %>% | |
arrange(desc(count)) | |
# create separate dataframes for each gender | |
all_shootings_men_with_gun <- gun_police_shootings_by_gender %>% | |
filter(gender == 'M') | |
all_shootings_women_with_gun <- gun_police_shootings_by_gender %>% | |
filter(gender == 'F') | |
# calculate percentages for both using the count column - I'll leave that to you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment