Rationale

Agenda-setting predicts that mass media influences what their audience perceives as an impoartant topic. Meaning, if one topic is produced more than others the audience will think about said topic more. Thus, the audience sees it as more important. First level agenda-setting is how topics compete for salience on the media agenda. Unlike second and third level agenda setting, where components within a topic compete for salience, first level agenda setting deals with two different topics. Both of these topics may be within the same category but took place separately. Mass media then decides which of these stories takes priority and will receive more coverage. However, it is not always one or the other, these stories may trade places or be more consistent in coverage with each other.

Drawing on what first-level agenda-setting theory says about this phenomenon, my project will compare the media agenda prominence of two issues: Issues related to Pope Francis, before and after his death, and issues related to Pope Leo XIV, before and after his election. 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 - The ruling and death of a Catholic Pope and the election and subsequent ruling of a new one- compete for attention on the media agenda.

Hypothesis

Weekly APNews.com coverage volume of Pope Francis and Pope Leo XIV differed during the first nine months of 2025.

Variables & Method

Weekly APNews.com coverage volume of the two Popes 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 “Pope Francis” or “Pope Leo” and operationalized as containing key words unique to stories about one topic or the other. The key words used were “Pope Francis” and “Pope Leo”.

Results & Discussion

The figure below summarizes each story topic’s weekly coverage volume across the period analyzed. It appears that, for most weeks, APNews.com coverage of Pope Francis exceeded APNews.com coverage volume of Pope Leo XIV.

The most notable difference in volume appeared during week 17 which was the week between April 21 and April 27. The weekly Pope Francis related story count peaked at a period high of 125, compared to 0 for Pope Leo XIV. An examination of the Pope Francis related stories published during that week revealed heavy coverage due to Pope Francis’ death on April 21. On the other hand coverage of Pope Leo XIV is 0 due to him not being elected yet as the new Pope.

The peak for Pope Leo Related stories appeared during week 19, the week between May 5 and May 11. The weekly Pope Leo XIV related story count peaked at a period high of 42, compared to 23 for Pope Francis. An examination of the Pope Leo XIV related stories published during that week revealed heavy coverage due to the election Pope Leo XIV on May 8.

Overall, the results suggest not only differing levels of APNews.com coverage about the two Popes but also possible nonrandom links between the level of coverage about one and the level of coverage about the other.

# ============================================
# 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(
  "Pope Francis"
)

# --- 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(
  "Pope Leo"
)

# --- 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 = "Pope Francis") # 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 = "Pope Leo") # 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