OpenStates from R via API: watch your elected representatives

June 10, 2011
By

(This article was first published on Recology, and kindly contributed to R-bloggers)

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"
Created by Pretty R at inside-R.org


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 his blog: Recology.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.