Rationale

The first-level agenda-setting theory explains how the media influences what issues the public perceives as most important. According to this theory, the more frequently and prominently a topic is covered by the media, the more likely people are to consider that issue significant. In other words, the media doesn’t tell audiences what to think, but rather what to think about. By choosing which stories to highlight and how much attention to give them. Therefore, news organizations shape the public agenda guiding collective attention toward certain political, social, or economic problems. This process plays a crucial role in public opinion formation and in setting the priorities of both citizens and policymakers.

Based on the hypothesis of this theory, my project will compare the media coverage of two MLB teams: The Los Angeles Dodgers and the Toronto Blue Jays. Specifically, the analysis will compare the number of stories per week that APNews.com published about each team between January 1st and September 30, 2025.   

The results will enhance theoretical understanding of how similar but yet different teams, both finalists in the MLB world series compete for attention on the media agenda. 

Hypothesis

Weekly APNews.com coverage volume for the Toronto Blue Jays was higher than the coverage of the Los Angeles Dodgers. 

Variables & method

Weekly APNews.com coverage volume of the two teams served as the analysis’s dependent variable. It was measured continuously as the number of stories published per week. The independent variable was the “story topic” measured categorically as either “Dodgers” or “BlueJays”. Key phrases and words used to identify stories about Dodgers were: “Los Angeles Dodgers,” and “World Series”. Key words for stories about Toronto Blue Jays were: “Toronto Blue Jays” and “World Series.”

Results & discussion

The results of the analysis are displayed in an interactive line chart showing weekly counts of AP News articles that mentioned either the Los Angeles Dodgers or  the Toronto Blue Jays. The visualization revealed variation in the number of stories published about each topic from week to week, reflecting fluctuations in the amount of media attention devoted to each. Periods where one line spiked above the other indicated weeks when that topic received heightened coverage, suggesting an increase in its salience within the media agenda. Weeks with few or no mentions represented times when that issue received little to no media attention, reducing its visibility to the public.

Interpreted through the lens of the first-level agenda-setting theory, these results illustrate how the frequency of media coverage can influence which issues the public perceives as most important. The consistent or increased mention of one topic over another indicates that the media prioritized certain issues or individuals, thereby shaping public awareness and potentially influencing political discourse. Spikes in coverage likely correspond to specific events or developments related to each topic that temporarily raised their news value. Overall, this analysis demonstrates that by tracking and visualizing article frequency over time, it is possible to observe the agenda-setting effects of media coverage and better understand how attention to specific topics fluctuates within the news cycle.

Code:

# ============================================
# 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(
  "Los Angeles Dogers",
  "World Series"
)

# --- 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(
  "Toronto Blue Jays",
  "World Series"
)

# --- 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 = "Dodgers") # 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 = "BlueJays") # 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