Skip to content

Instantly share code, notes, and snippets.

@sckott
Last active August 29, 2015 13:57
Show Gist options
  • Save sckott/9648948 to your computer and use it in GitHub Desktop.
Save sckott/9648948 to your computer and use it in GitHub Desktop.

Install and load package

install_github("ropengov/rsunlight")
library(ropengov)

Search for data

df <- os_billsearch(terms = "drone")

Clean up

Some elements in the list are list(), which makes it hard to combine to a data.frame. Soon I'll fix these in the package itself.

df <- lapply(df, function(x){ 
  x[sapply(x, length)==0] <- "none"
  x
})

Make a data.frame

Using plyr package. Removing first column for display here as it's a long character string.

library(plyr)
dat <- ldply(df, data.frame)
head(dat[,-1])
           created_at          updated_at          id chamber state session type                          subjects bill_id
1 2014-01-21 19:22:39 2014-03-19 03:17:52 TNB00015037   upper    tn     108 bill              Agriculture and Food SB 1777
2 2014-01-21 19:22:39 2014-03-19 03:17:52 TNB00015037   upper    tn     108 bill Animal Rights and Wildlife Issues SB 1777
3 2014-02-15 00:46:13 2014-03-14 23:56:26 AKB00001323   upper    ak      28 bill                             Drugs  SB 173
4 2014-02-15 00:46:13 2014-03-14 23:56:26 AKB00001323   upper    ak      28 bill                   Public Services  SB 173
5 2014-02-15 00:46:13 2014-03-14 23:56:26 AKB00001323   upper    ak      28 bill                            Health  SB 173
6 2014-02-15 00:46:13 2014-03-14 23:56:26 AKB00001323   upper    ak      28 bill                     Social Issues  SB 173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment