OpenStates from R via API: watch your elected representatives

[This article was first published on Recology, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I am writing some functions to acquire data from the OpenStates project, via their API. They have a great support community at Google Groups as well.

On its face this post is not obviously about ecology or evolution, but well, our elected representatives do, so to speak, hold our environment in a noose, ready to let the Earth hang any day.

Code I am developing is over at Github.

Here is an example of its use in R, in this case using the Bill Search option (billsearch.R on my Github site), and in this case you do not provide your API key in the function call, but instead put it in your .Rprofile file, which is called when you open R. We are searching here for the term ‘agriculture’ in Texas (‘tx’), in the ‘upper’ chamber.

> temp <- billsearch('agriculture', state = 'tx', chamber = 'upper')
 
> length(temp)
[1] 21
 
> temp[[1]]
$title
[1] "Congratulating John C. Padalino of El Paso for being appointed to the United States Department of Agriculture."
 
$created_at
[1] "2010-08-11 07:59:46"
 
$updated_at
[1] "2010-09-02 03:34:39"
 
$chamber
[1] "upper"
 
$state
[1] "tx"
 
$session
[1] "81"
 
$type
$type[[1]]
[1] "resolution"
 
 
$subjects
$subjects[[1]]
[1] "Resolutions"
 
$subjects[[2]]
[1] "Other"
 
 
$bill_id
[1] "SR 1042"



Apparently, the first bill (SR 2042, see $bill_id at the bottom of the list output) that came up was to congratulate John Paladino for being appointed to the USDA.

The other function I have ready is getting basic metadata on a state, called statemetasearch.

I plan to develop more functions for all the possible API calls to the OpenStates project.

To leave a comment for the author, please follow the link and comment on their blog: Recology.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)