Git Product home page Git Product logo

legiscanrr's Introduction

legiscanrr

lifecycle

The goal of legiscanrr is to provide tools in R to easily interact with the LegiScan API. You can use the API to retrieve information about legislations in US states and Congress, such as bill details, sponsors, full bill texts, roll call records and more.

This package contains two main groups of functions:

  • Wrapper functions for LegiScan APi operations to retrieve information from LegiScan API.
    • API key from LegiScan is required. Register for a key here
  • Data processing functions to parse information such as bill metadata, bill sponsor, roll call votes, from the JSON files retrieved via API or direct download

For full reference of the package, see https://fanghuiz.github.io/legiscanrr/

Installation

You can install the development version from GitHub with:

install.packages("devtools")
devtools::install_github("fanghuiz/legiscanrr")

Example

library(legiscanrr)

Get bill details via API using get_bill()

bill_example <- get_bill(bill_id = 230086)

head(bill_example)
#> $bill_id
#> [1] 230086
#> 
#> $change_hash
#> [1] "f29fef5ddcea1b65cee12357ac828383"
#> 
#> $session_id
#> [1] 122
#> 
#> $session
#> $session$session_id
#> [1] 122
#> 
#> $session$session_name
#> [1] "27th Legislature"
#> 
#> $session$session_title
#> [1] "27th Legislature"
#> 
#> $session$year_start
#> [1] 2011
#> 
#> $session$year_end
#> [1] 2012
#> 
#> $session$special
#> [1] 0
#> 
#> 
#> $url
#> [1] "https://legiscan.com/AK/bill/HB3/2011"
#> 
#> $state_link
#> [1] "http://www.legis.state.ak.us/basis/get_bill.asp?session=27&bill=HB3"

Extract bill metadata using parse_bill()

bill_meta <- parse_bill(bill_example)

str(bill_meta)
#> Classes 'tbl_df', 'tbl' and 'data.frame':    1 obs. of  24 variables:
#>  $ bill_id             : int 230086
#>  $ change_hash         : chr "f29fef5ddcea1b65cee12357ac828383"
#>  $ url                 : chr "https://legiscan.com/AK/bill/HB3/2011"
#>  $ state_link          : chr "http://www.legis.state.ak.us/basis/get_bill.asp?session=27&bill=HB3"
#>  $ status              : int 2
#>  $ status_date         : chr "2011-02-28"
#>  $ state               : chr "AK"
#>  $ state_id            : int 2
#>  $ bill_number         : chr "HB3"
#>  $ bill_type           : chr "B"
#>  $ bill_type_id        : chr "1"
#>  $ body                : chr "H"
#>  $ body_id             : int 13
#>  $ current_body        : chr "S"
#>  $ current_body_id     : int 14
#>  $ title               : chr "Requirements For Driver's License"
#>  $ description         : chr "An Act relating to issuance of driver's licenses."
#>  $ pending_committee_id: int 2149
#>  $ session_id          : int 122
#>  $ session_name        : chr "27th Legislature"
#>  $ session_title       : chr "27th Legislature"
#>  $ year_start          : int 2011
#>  $ year_end            : int 2012
#>  $ special             : int 0

Extract bill progress information using parse_bill_progress()

parse_bill_progress(bill_example)
#>          date event bill_id
#> 1: 2011-01-18     1  230086
#> 2: 2011-01-18     9  230086
#> 3: 2011-02-02    11  230086
#> 4: 2011-02-23    10  230086
#> 5: 2011-02-28     2  230086
#> 6: 2011-03-01     9  230086

Extract information about sponsors for this bill using parse_bill_sponsor()

sponsor <- parse_bill_sponsor(bill_example)

str(sponsor)
#> Classes 'data.table' and 'data.frame':   19 obs. of  9 variables:
#>  $ people_id        : int  6033 11587 11300 11299 11277 6071 6068 6067 6064 6063 ...
#>  $ party_id         : int  2 2 2 2 2 2 1 2 2 2 ...
#>  $ party            : chr  "R" "R" "R" "R" ...
#>  $ name             : chr  "Carl Gatto" "Steve Thompson" "Lance Pruitt" "Eric Feige" ...
#>  $ sponsor_type_id  : int  0 0 0 0 0 0 0 0 0 0 ...
#>  $ sponsor_order    : int  0 0 0 0 0 0 0 0 0 0 ...
#>  $ committee_sponsor: int  0 0 0 0 0 0 0 0 0 0 ...
#>  $ committee_id     : chr  "0" "0" "0" "0" ...
#>  $ bill_id          : int  230086 230086 230086 230086 230086 230086 230086 230086 230086 230086 ...
#>  - attr(*, ".internal.selfref")=<externalptr>

Data structure

Dataset structure and keys for joining different tables.

legiscanrr's People

Contributors

fanghuiz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mlwier99

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.