fivethirtyeight / data

Data and code behind the articles and graphics at FiveThirtyEight
https://data.fivethirtyeight.com/
Creative Commons Attribution 4.0 International
16.74k stars 10.94k forks source link

Change scrape.R in police-deaths #195

Closed tylerlittlefield closed 1 year ago

tylerlittlefield commented 6 years ago

Change scrape.R so that it scrapes all the data.

Currently scrape.R gives:

[1] person dept   eow    cause 
<0 rows> (or 0-length row.names)

The modified scrape.R now gives:

# A tibble: 23,436 x 4
   person                          dept                                          eow                   cause     
   <chr>                           <chr>                                         <chr>                 <chr>     
 1 Constable Darius Quimby         Albany County Constable's Office, NY          EOW: Monday, January… Cause: Gu…
 2 Sheriff Cornelius Hogeboom      Columbia County Sheriff's Office, NY          EOW: Saturday, Octob… Cause: Gu…
 3 Deputy Sheriff Isaac Smith      Westchester County Sheriff's Department, NY   EOW: Thursday, May 1… Cause: Gu…
 4 Marshal Robert Forsyth          United States Department of Justice - United… EOW: Saturday, Janua… Cause: Gu…
 5 Sheriff Robert Maxwell          Greenville County Sheriff's Office, SC        EOW: Sunday, Novembe… Cause: Gu…
 6 High Sheriff John Caldwell Cook Mecklenburg County Sheriff's Office, NC       EOW: Tuesday, Octobe… Cause: Gu…
 7 Watchman Christian Luswanger    New York City Watch, NY                       EOW: Thursday, Decem… Cause: St…
 8 Deputy Sheriff John A. Gooch    Livingston County Sheriff's Department, KY    EOW: Saturday, March… Cause: Gu…
 9 Deputy Sheriff Ebenezer Parker  Cumberland County Sheriff's Office, ME        EOW: Monday, January… Cause: As…
10 Night Watchman George Workner   Baltimore City Police Department, MD          EOW: Tuesday, March … Cause: St…
# ... with 23,426 more rows

I'd be happy to modify the original code as well if the for loop is preferred over the dplyr chain or if a data.frame is preferred over a tibble.