First-level agenda-setting theory examines how specific topics compete for prominence on the media agenda. If the media believes one issue is more critical than the other, the other topic may not be discussed as much. Depending on the seriousness of the topics and the subjects, both issues may be highly prominent at the same time.
In the current political climate, the United States is still adjusting to a new presidential administration and set of policies; my project will compare the media agenda prominence of two topics: tariffs and immigration. These are two topics that President Donald Trump discussed a lot while running for office, and they’ve dominated news headlines in 2025. They’re topics that a lot of Americans care about.
The analysis will compare the number of stories per week that APNews.com published about each issue between Jan. 1 and Sept. 30, 2025. The results will enhance theoretical understanding of how similar-but-distinct issues that affect the American people and how America is perceived compete for attention on the media agenda.
Weekly APNews.com coverage volume of topics related to Tariffs and Immigration varied during the first nine months of 2025.
Weekly APNews.com coverage volume of the two topics served as the analysis’s dependent variable. It was measured continuously as the number of stories published per week. The independent variable was “story topic,” measured categorically as either “Tariffs” or “Immigration” and operationalized as containing key words or phrases likely to be unique to stories about one topic or the other. Key words and phrases used to identify stories about Tariffs were: “Tariffs”, “Tariff”, “Trade war”, “Import tax”, “Trade deal”, and “Sanctions”. Key words and phrases used to identify stories about Immigration were: “Immigration”, “Border”, “Asylum”, “Deportation”, and “ICE”.
Eventually, I will use a paired-samples t-test to assess the statistical significance of the difference in coverage volume between the two story topics.
The figure below summarizes each story topic’s weekly coverage volume across the period analyzed. It appears that APNews.com coverage for Immigration and Tariffs was strong throughout the year, and both topics had their moments.
The first notable difference in volume appeared during Week 4. The weekly Immigration-related story count peaked at a period high of 83 compared to only 21 for Tariffs. A quick dive into articles that week reveals it was Mr. Trump’s first week in office. Immigrants were concerned about what the future looked like; the administration was reporting the border was getting more secure, and his administration was fulfilling his pledge to crack down on immigration.
The peak for Tariff-related stories appeared during Week 10, Week 14, and Week 15. This is because there was a lot of coverage about Tariffs being imposed on countries like Mexico, Canada, and China. Also, the reciprocal tariffs.
In Week 24, Immigration-related stories peak higher than Tariffs again because immigration enforcement raids and protests pick up around the country.
Overall, the results suggest not only differences in APNews.com coverage of the two topics but also possible nonrandom links between the levels of coverage of one and the other.
Code:
Here is the code that produced the figure.
# ============================================
# APNews text analysis (First-level agenda-setting theory version)
# ============================================
# ============================================
# --- Load required libraries ---
# ============================================
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("tidytext")) install.packages("tidytext")
library(tidyverse)
library(tidytext)
# ============================================
# --- Load the APNews data ---
# ============================================
# Read the data from the web
FetchedData <- readRDS(url("https://github.com/drkblake/Data/raw/refs/heads/main/APNews.rds"))
# Save the data on your computer
saveRDS(FetchedData, file = "APNews.rds")
# remove the downloaded data from the environment
rm (FetchedData)
APNews <- readRDS("APNews.rds")
# ============================================
# --- Flag Topic1-related stories ---
# ============================================
# --- Define Topic1 phrases ---
phrases <- c(
"Tariff",
"Trade war",
"Import tax",
"Trade deal",
"Sanctions",
"Tariffs"
)
# --- Escape regex special characters ---
escaped_phrases <- str_replace_all(
phrases,
"([\\^$.|?*+()\\[\\]{}\\\\])",
"\\\\\\1"
)
# --- Build whole-word/phrase regex pattern ---
pattern <- paste0("\\b", escaped_phrases, "\\b", collapse = "|")
# --- Apply matching to flag Topic1 stories ---
APNews <- APNews %>%
mutate(
Full.Text.clean = str_squish(Full.Text), # normalize whitespace
Topic1 = if_else(
str_detect(Full.Text.clean, regex(pattern, ignore_case = TRUE)),
"Yes",
"No"
)
)
# ============================================
# --- Flag Topic2-related stories ---
# ============================================
# --- Define Topic2 phrases ---
phrases <- c(
"Immigration",
"Border",
"Asylum",
"Deportation",
"ICE"
)
# --- Escape regex special characters ---
escaped_phrases <- str_replace_all(
phrases,
"([\\^$.|?*+()\\[\\]{}\\\\])",
"\\\\\\1"
)
# --- Build whole-word/phrase regex pattern ---
pattern <- paste0("\\b", escaped_phrases, "\\b", collapse = "|")
# --- Apply matching to flag Topic2 stories ---
APNews <- APNews %>%
mutate(
Full.Text.clean = str_squish(Full.Text),
Topic2 = if_else(
str_detect(Full.Text.clean, regex(pattern, ignore_case = TRUE)),
"Yes",
"No"
)
)
# ============================================
# --- Visualize weekly counts of Topic1- and Topic2-related stories ---
# ============================================
# --- Load plotly if needed ---
if (!require("plotly")) install.packages("plotly")
library(plotly)
# --- Summarize weekly counts for Topic1 = "Yes" ---
Topic1_weekly <- APNews %>%
filter(Topic1 == "Yes") %>%
group_by(Week) %>%
summarize(Count = n(), .groups = "drop") %>%
mutate(Topic = "Tariffs") # Note custom Topic1 label
# --- Summarize weekly counts for Topic2 = "Yes" ---
Topic2_weekly <- APNews %>%
filter(Topic2 == "Yes") %>%
group_by(Week) %>%
summarize(Count = n(), .groups = "drop") %>%
mutate(Topic = "Immigration") # Note custom Topic2 label
# --- Combine both summaries into one data frame ---
Weekly_counts <- bind_rows(Topic2_weekly, Topic1_weekly)
# --- Fill in missing combinations with zero counts ---
Weekly_counts <- Weekly_counts %>%
tidyr::complete(
Topic,
Week = full_seq(range(Week), 1), # generate all week numbers
fill = list(Count = 0)
) %>%
arrange(Topic, Week)
# --- Create interactive plotly line chart ---
AS1 <- plot_ly(
data = Weekly_counts,
x = ~Week,
y = ~Count,
color = ~Topic,
colors = c("steelblue", "firebrick"),
type = "scatter",
mode = "lines+markers",
line = list(width = 2),
marker = list(size = 6)
) %>%
layout(
title = "Weekly Counts of Topic1- and Topic2-Related AP News Articles",
xaxis = list(
title = "Week Number (starting with Week 1 of 2025)",
dtick = 1
),
yaxis = list(title = "Number of Articles"),
legend = list(title = list(text = "Topic")),
hovermode = "x unified"
)
# ============================================
# --- Show the chart ---
# ============================================
AS1