Git Product home page Git Product logo

city-cops's Introduction

city-cops

Scripts to scrape data on city police budgets

  • scrape.R: code to scrape city-data.com
  • nv.rds: example dataset (Nevada)

Issues:

  • Connection will be blocked by host if you make too many requests
  • dates scraped from web still interpreted as chr vectors instead of datetimes

Example Use:

# Get URLS for each city
city_urls <- states$URL %>%
  map_df(get_city_urls) 

# Get budgets for entire country
city_budgets <- city_urls$URL %>% 
  map_df(get_city_payroll)

# get budgets, single state
nv_urls <- city_urls %>% 
  filter(URL %>% str_detect("Nevada.html")) 
nv_budgets <- nv_urls$URL %>% 
  map_df(get_city_payroll)

Example Output:

> nv_budgets
# A tibble: 326 x 9
   state  city      Function                 date_str   `Full-time_employe… `Part-time_employe… `Monthly_full-time_pay… `Average_yearly_full-tim… `Monthly_part-time_pay…
   <chr>  <chr>     <chr>                    <chr>                    <dbl>               <dbl>                   <dbl>                     <dbl>                   <dbl>
 1 Nevada Carson C… Correction               March 2016                  69                  12                  393180                     68379                   18111
 2 Nevada Carson C… Police Protection - Off… March 2016                  65                   0                  419167                     77385                       0
 3 Nevada Carson C… Judicial and Legal       March 2016                  63                   5                  368178                     70129                    9902
 4 Nevada Carson C… Firefighters             March 2016                  59                   5                  475073                     96625                    2682
 5 Nevada Carson C… Streets and Highways     March 2016                  49                   0                  268154                     65670                       0
 6 Nevada Carson C… Financial Administration March 2016                  34                   5                  191263                     67505                    4189
 7 Nevada Carson C… Police - Other           March 2016                  30                   7                  170473                     68189                    7832
 8 Nevada Carson C… Other Government Admini… March 2016                  29                   5                  155354                     64284                    5917
 9 Nevada Carson C… Other and Unallocable    March 2016                  29                   4                  141163                     58412                    5146
10 Nevada Carson C… Health                   March 2016                  28                   9                  155853                     66794                   17413
# … with 316 more rows

city-cops's People

Contributors

rgzn avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.