Skip to content

Instantly share code, notes, and snippets.

@benmarwick
Created March 1, 2018 02:13
Show Gist options
  • Select an option

  • Save benmarwick/daf9e42e5a012b22efd9f4902e39239e to your computer and use it in GitHub Desktop.

Select an option

Save benmarwick/daf9e42e5a012b22efd9f4902e39239e to your computer and use it in GitHub Desktop.
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