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 = '2020',
district = '02',
state = 'TN',
unnest_committees = TRUE
)
committee_reports <- committees %>%
get_committee_reports()
# Wrangle Data
chart_data <- committee_reports %>%
filter(type_of_funds == 'individual_itemized_contributions_period',
cycle == '2020') %>%
mutate(document_description = fct_relevel(document_description,
c('APRIL QUARTERLY 2019',
'JULY QUARTERLY 2019',
'OCTOBER QUARTERLY 2019',
'YEAR-END 2019',
'TERMINATION REPORT 2019',
'APRIL QUARTERLY 2020',
'JULY QUARTERLY 2020',
'OCTOBER QUARTERLY 2020',
'YEAR-END 2020',
'TERMINATION REPORT 2020',
'PRE-PRIMARY 2020',
'PRE-GENERAL 2020',
'POST-GENERAL 2020'
)
))
# 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 = 'Tennessee Congressional District 02 Race - 2020',
subtitle = 'Individual Itemized Contributions by Period',
x = '',
y = '',
fill = 'Party',
caption = paste0('Source: FEC. Data retreived on ', Sys.Date(), ', created by @StephenHolz')
)