knitr::opts_chunk$set(fig.retina=2)

voteogram

U.S. House and Senate Voting Cartogram Generators

Description

'ProPublica' https://projects.propublica.org/represent/ makes United States Congress member votes available and has developed their own unique cartogram to visually represent this data as has 'GovTrack' . Tools are provided to retrieve voting data, prepare voting data for plotting with 'ggplot2', create vote cartograms and theme them.

Ref: (these are replicated below)

You can grab the results of a roll call vote (House or Senate) with roll_call(). It returns a list with a ton of information that you can use outside this package. One element of that list is the data.frame of vote results. You can pass in the entire object to either _carto() function and it'll "fortify" it before shunting it off to ggplot2. Try to cache this data (I do, below, in R markdown chunk) as you're ticking credits off of ProPublica's monthly free S3 allotment each call. Consider donating to them if you're too lazy to cache the data).

TODO

What's In The Tin

The following functions are implemented:

Helpers:

Working with voteogram

Installation

remotes::install_github("hrbrmstr/voteogram")
options(width=120)

Basic Usage

library(voteogram)
library(hrbrthemes)
library(ggplot2)

# current verison
packageVersion("voteogram")
sen <- roll_call("senate", 115, 1, 110)
rep <- roll_call("house", 115, 1, 256)
str(sen)

sen$votes
str(rep)

fortify(rep)

ProPublica

senate_carto(sen) +
  labs(title="Senate Vote 110 - Invokes Cloture on Neil Gorsuch Nomination") +
  theme_ipsum_rc(plot_title_size = 24) +
  theme_voteogram()
house_carto(rep, pp_square=TRUE) +
  labs(x=NULL, y=NULL, 
       title="House Vote 256 - Passes American Health Care Act,\nRepealing Obamacare") +
  theme_ipsum_rc(plot_title_size = 24) +
  theme_voteogram()
house_carto(rep, pp_square=FALSE) +
  labs(x=NULL, y=NULL, 
       title="House Vote 256 - Passes American Health Care Act,\nRepealing Obamacare") +
  theme_ipsum_rc(plot_title_size = 24) +
  theme_voteogram()

GovTrack

house_carto(rep, "gt") +
  labs(x=NULL, y=NULL, 
       title="House Vote 256 - Passes American Health Care Act,\nRepealing Obamacare") +
  theme_ipsum_rc(plot_title_size = 24) +
  theme_voteogram()

Tiny Cartograms

They can be shrunk down well (though that means annotating them in some other way):

senate_carto(sen) + theme_voteogram(legend=FALSE)
house_carto(rep) + theme_voteogram(legend=FALSE)
house_carto(rep, pp_square=TRUE) + theme_voteogram(legend=FALSE)

Test Results

library(voteogram)
library(testthat)

date()

test_dir("tests/")

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.



hrbrmstr/voteogram documentation built on March 12, 2023, 8:06 a.m.