Created
March 1, 2018 02:13
-
-
Save benmarwick/daf9e42e5a012b22efd9f4902e39239e to your computer and use it in GitHub Desktop.
Get data from https://mappingpoliceviolence.org/ and http://www.fatalencounters.org/
This file contains hidden or 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
| library(googlesheets) | |
| library(readxl) | |
| library(httr) | |
| #------------------------------------------------------------- | |
| # mapping police violence, https://mappingpoliceviolence.org/ | |
| # get google sheet info | |
| mapping_police_violence <- gs_url("https://docs.google.com/spreadsheets/d/1dKmaV_JiWcG8XBoRgP8b4e9Eopkpgt7FL7nyspvzAsE/edit#gid=0") | |
| # what are the sheet names? | |
| mapping_police_violence$ws$ws_title | |
| # download data from worksheet "Form Responses" | |
| mapping_police_violence_data <- | |
| mapping_police_violence %>% | |
| gs_read_csv(ws = "Form Responses") | |
| # take a look | |
| glimpse(mapping_police_violence_data) | |
| #------------------------------------------------------------- | |
| # fatal encounters, http://www.fatalencounters.org/ | |
| # get the Excel file | |
| url <- "https://mappingpoliceviolence.org/s/MPVDatasetDownload-swac.xlsx" | |
| GET(url, write_disk(tf <- tempfile(fileext = ".xlsx"))) | |
| # what are the sheet names? | |
| excel_sheets(tf) | |
| # get data from the "2013-2017 Police Killings" sheet | |
| fatal_encounters_data <-read_excel(tf, "2013-2017 Police Killings") | |
| unlink(tf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment