The R code below can replicate this chart. You can get help installing R here. You can get help with the tidyusafec data retreival package here.
# Load R packages
library(tidyusafec)
library(tidyverse)
# Get Data
committees <- search_candidates(
office = 'H',
election_year = '2016',
district = '02',
state = 'WI',
unnest_committees = TRUE
)
committee_reports <- committees %>%
get_committee_reports()
# Wrangle Data
chart_data <- committee_reports %>%
filter(type_of_funds == 'individual_unitemized_contributions_period',
cycle == '2016') %>%
mutate(document_description = fct_relevel(document_description,
c('APRIL QUARTERLY 2015',
'JULY QUARTERLY 2015',
'OCTOBER QUARTERLY 2015',
'YEAR-END 2015',
'TERMINATION REPORT 2015',
'APRIL QUARTERLY 2016',
'JULY QUARTERLY 2016',
'OCTOBER QUARTERLY 2016',
'YEAR-END 2016',
'TERMINATION REPORT 2016',
'PRE-PRIMARY 2016',
'PRE-GENERAL 2016',
'POST-GENERAL 2016'
)
))
# Visualize Data
ggplot(data = chart_data) +
geom_bar(aes(x = name, y = amount, fill = party), stat = 'identity') +
coord_flip() +
facet_wrap(~document_description, labeller = label_wrap_gen(width = 10)) +
scale_fill_manual(values = c('DEM' = '#2c4d82', 'REP' = '#8e1b1b', 'IND' = '#a3a3a3', 'GRE' = '#1c561d', 'LIB' = '#afac3d','NNE' = '#0A0A0A')) +
scale_y_continuous(labels = scales::dollar) +
theme_bw() +
theme(axis.text.x = element_text(angle = -90, hjust = 0, vjust = .5)) +
labs(
title = 'Wisconsin Congressional District 02 Race - 2016',
subtitle = 'Individual Unitemized Contributions by Period',
x = '',
y = '',
fill = 'Party',
caption = paste0('Source: FEC. Data retreived on ', Sys.Date(), ', created by @StephenHolz')
)