By examining APNews coverage over the past year, we can assess whether the news outlet gives more attention to Travis Kelce, a tight end, compared to Patrick Mahomes, a quarterback. Agenda-setting theory uses media coverage to compare what the audience thinks about more in comparison of two topics. To determine the answer between Travis and Patrick, we use first-level agenda-setting theory to see the switch from athletic performance to celebrity status.
Travis Kelce, due to his recent engagement to Taylor Swift, has received more APNews coverage than his quarterback, Patrick Mahomes.
The independent variable, which is categorical, is Patrick Mahomes and Travis Kelce. The dependent variable, which is continuous, is the number of APNews articles that mention them by name. The method for this analysis is the APNews dataset since January 1st, 2025. Using keywords that identify Travis Kelce and Patrick Mahomes. Counting the number of mentions through the graph provided you can compare the data to understand the popularity of the two people.
The results support the hypothesis. Specifically, with the addition of Taylor Swift and Travis Kelce’s engagement (week 35), you see that Travis had 19 articles compared to the two Patrick had. There are a few weeks that Patrick has more stories than Travis,12 out of 40 weeks. You see that Patrick has more stories written about him than Travis. Patrick’s highest amount of stories in one week is 10 (Week 6), and Travis’s is 19 (Week 35). Overall, I was surprised that there wasn’t a huge difference between Travis and Patrick on APNews, but the hypothesis is still supported.
# ============================================
# APNews Data Fetch & Word Frequency Analysis
# ============================================
# --- Load required libraries ---
if (!require("tidyverse")) install.packages("tidyverse")
if (!require("tidytext")) install.packages("tidytext")
library(tidyverse)
library(tidytext)
# ============================================
# --- Retrieve save the data file ---
# ============================================
# 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(
"travis kelce",
"kelce",
"chiefs tight end",
"taylor swift and travis",
"travis kelce relationship",
"travis kelce touchdown",
"travis kelce super bowl",
"travis kelce interview",
"travis kelce game",
"travis kelce news"
)
# --- 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(
"patrick mahomes",
"mahomes",
"chiefs quarterback",
"mahomes touchdown",
"mahomes super bowl",
"mahomes game",
"mahomes interview",
"patrick mahomes and brittany mahomes",
"mahomes news"
)
# --- 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 = "Travis") # 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 = "Patrick") # 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
# Paste - again - your complete R script, the same one pasted into the first code chunk, above. Pasting it were will display it.