Skip to content

Instantly share code, notes, and snippets.

@jlopezper
Created June 2, 2020 08:40
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 jlopezper/8b14d4bbee7a507e6fe395b360cf6e60 to your computer and use it in GitHub Desktop.
Save jlopezper/8b14d4bbee7a507e6fe395b360cf6e60 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(lubridate)
tst <- readr::read_csv('https://raw.githubusercontent.com/washingtonpost/data-police-shootings/master/fatal-police-shootings-data.csv')
tst1 <-
tst %>%
filter(race != 'N', year(date) < 2020) %>%
mutate(Raza = ifelse(race == 'W', 'Blancos', 'Otros')) %>%
filter(armed == 'unarmed') %>%
group_by(year = year(date), Raza) %>%
summarise(n = n())
tst %>%
count(armed) %>%
filter(n > 10) %>%
filter(!is.na(armed)) %>%
ggplot(aes(x = reorder(armed, n), y = n)) +
geom_bar(stat="identity") +
coord_flip() + theme_minimal() +
labs(x = 'Situación')
ggplot(tst1, aes(x = year, y = n, group = Raza)) +
geom_line(aes(color = Raza)) +
geom_point(aes(color = Raza)) + theme_minimal() +
labs(title= 'Número de personas desarmadas muertas por disparos policiales')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment