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 = 'S',
election_year = '2016',
district = '00',
state = 'WA',
unnest_committees = TRUE
)
committee_reports <- committees %>%
get_committee_reports()
# Wrangle Data
chart_data <- committee_reports %>%
filter(type_of_funds == 'candidate_contribution_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 = 'Washington Senate Race - 2016',
subtitle = 'Candidate Contributions by Period',
x = '',
y = '',
fill = 'Party',
caption = paste0('Source: FEC. Data retreived on ', Sys.Date(), ', created by @StephenHolz')
)