Using data from ProPublica's Bulk Data on Bills and an API key, these scripts generate and visualize cosponsor relationships between legislators.
- httr
- jsonlite
- igraph
- ggraph
Clone this repo with
git clone https://github.com/blakemoya/congressional_networks
Use this link to download a zip file containing data on all the bills introduced by a Congress in some particular year. The file will be named after that Congress's number (i.e. the 115th Congress will give you 115.zip
)
Extract the file/files of interest into the congressional_networks
directory.
Use this link to request an API key.
Save the key emailed to you in a .txt
file called api_key.txt
followed by an empty line (i.e. copy and paste in the key, then press enter and save).
Copy this file into the congressional_networks
directory.
Then, in line 5 of both gen_graphfiles.R
and gen_plots.R
set the variable congress
to the congress you are interested in.
For instance, if I downloaded and extracted 115.zip
:
congress = 115
Once this is done, you can run gen_graphfiles.R
(in RStudio, Ctrl + A, Ctrl + Enter
) and then gen_plots.R
. gen_plots.R
takes a lot of time to produce house graphs, but the results are well worth it.