library(tidyverse)
library(haven)
library(readr)
I think the issue with the survey question is the combination of wording, specifically “gridlock” and “dysfunction,” because to me, it feels like it places a harsh connotation on the question that may sway survey respondents from thinking critically. There is also a lack of information to help respondents recall the event.
Additionally, the answer options do not make much sense.
Who do you believe caused the 43-day legislative gridlock in Washington in 2025?
I considered separating Congress into the House and Senate, along with removing Biden since he is not really a factor. However, I feel like these choices are straightforward and easy to answer.
sept_data <- read_csv("meta/FacebookAdLibraryReport_2024-09-01_US_yesterday_locations.csv")
## New names:
## Rows: 56 Columns: 3
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (2): Location name, Amount spent (USD) dbl (1): ...1
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...1`
sept_data$spent <- as.numeric(
gsub(",", "", gsub("≤", "", sept_data[["Amount spent (USD)"]])))
sept_data[which.max(sept_data$spent), ]
## # A tibble: 1 × 4
## ...1 `Location name` `Amount spent (USD)` spent
## <dbl> <chr> <chr> <dbl>
## 1 40 Pennsylvania 234238 234238
sum(sept_data$spent, na.rm = TRUE)
## [1] 2455487
sept_data$date <- as.Date("2024-09-01")
dates <- seq(
as.Date("2024-09-02"),
as.Date("2024-11-30"),
by = "day")
length(dates)
## [1] 90
all_data <- list.files("meta",
pattern = "\\.csv$",
full.names = TRUE)
all_data <- all_data[
!grepl("2024-09-01", basename(all_data))]
all_data <- sort(all_data)
length(all_data)
## [1] 91
all_data <- paste0(
"meta/FacebookAdLibraryReport_",
dates,
"_US_yesterday_locations.csv")
names(sept_data) <- make.names(names(sept_data))
combined_data <- data.frame(
state = sept_data[["Location.name"]],
spent = sept_data$spent,
date = sept_data$date)
for (i in 1:length(all_data)) {
total_data <- read_csv(all_data[i])
names(total_data) <- make.names(names(total_data))
total_data$spent <- as.numeric(
gsub(",", "", gsub("≤", "", total_data[["Amount.spent..USD."]])))
right_data <- data.frame(
state = total_data[["Location.name"]],
spent = total_data$spent,
date = dates[i])
combined_data <- rbind(combined_data, right_data)
}
head(combined_data)
## state spent date
## 1 Alabama 18727 2024-09-01
## 2 Alaska 8125 2024-09-01
## 3 American Samoa 100 2024-09-01
## 4 Arizona 101491 2024-09-01
## 5 Arkansas 12502 2024-09-01
## 6 California 218232 2024-09-01
daily <- aggregate(spent ~ date,
data = combined_data,
FUN = sum,
na.rm = TRUE)
head(daily)
## date spent
## 1 2024-09-01 2455487
## 2 2024-09-02 2385876
## 3 2024-09-03 2722227
## 4 2024-09-04 2728140
## 5 2024-09-05 2993057
## 6 2024-09-06 3102120
plot(daily$date, daily$spent,
type = "l",
col = "brown",
lwd = 2,
main = "Daily Spending on Meta Political Ads",
xlab = "Date",
ylab = "",
yaxt = "n")
axis(2, at = axTicks(2),
labels = paste0("$", format(axTicks(2),
big.mark = ",", scientific = FALSE)),
las = 1)
mtext("Money Spent", side = 2, line = 8)
The spike in political advertisement spending in September may be associated with the presidential debate between Kamala Harris and Donald Trump on September 10, 2024. Political advertisers may have increased their spending to influence voters surrounding the debate.
Spending also increased throughout October as Election Day approached, followed by a significant decline after the election.
swing_states <- c("Arizona", "Georgia", "Michigan",
"North Carolina", "Nevada", "Pennsylvania",
"Wisconsin")
combined_data$swings <- combined_data$state %in% swing_states
head(combined_data)
## state spent date swings
## 1 Alabama 18727 2024-09-01 FALSE
## 2 Alaska 8125 2024-09-01 FALSE
## 3 American Samoa 100 2024-09-01 FALSE
## 4 Arizona 101491 2024-09-01 TRUE
## 5 Arkansas 12502 2024-09-01 FALSE
## 6 California 218232 2024-09-01 FALSE
state_data <- combined_data[
combined_data$state %in% state.name,
]
daily_swing <- aggregate(
spent ~ date + swings,
data = state_data,
FUN = sum,
na.rm = TRUE)
head(daily_swing)
## date swings spent
## 1 2024-09-01 FALSE 1474662
## 2 2024-09-02 FALSE 1429259
## 3 2024-09-03 FALSE 1420490
## 4 2024-09-04 FALSE 1462263
## 5 2024-09-05 FALSE 1538479
## 6 2024-09-06 FALSE 1607871
swing <- daily_swing[daily_swing$swings == TRUE, ]
non_swing <- daily_swing[daily_swing$swings == FALSE, ]
plot(swing$date, swing$spent,
type = "l", col = "green",
ylim = range(daily_swing$spent),
main = "Swing vs. Non-Swing State Spending",
xlab = "Date",
ylab = "",
yaxt = "n")
axis(2,
at = axTicks(2),
labels = paste0("$", format(axTicks(2),
big.mark = ",", scientific = FALSE)),
las = 1, cex.axis = 0.85)
mtext("Spending (USD)", side = 2, line = 8)
lines(non_swing$date, non_swing$spent,
col = "brown")
legend("topleft",
legend = c("Swing States", "Non-Swing States"),
col = c("green", "brown"), lty = 1)
The spending increases in both swing and non-swing states in September spike