My analysis of the news headlines revealed several frequently used keywords, including “Iran,” “House,” “war,” “AI,” “oil” and “ICE.” These words suggest that much of the news coverage involving President Donald Trump centers on foreign affairs, government, technology and immigration.
One theme that stood out was the ongoing conflict involving Iran. The frequent appearance of words such as “Iran,” “war” and “oil” suggests a possible connection between international developments and economic concerns affecting Americans, including gas prices and the cost of living. Artificial intelligence and immigration enforcement also appear to be recurring topics. With the midterm elections approaching, these issues could play an important role in voter concerns.
I made several decisions about which words to include and exclude from my analysis. I removed common stop words, along with “Donald,” “Trump” and the word “top.” Since every article in the dataset mentions Donald Trump, I felt keeping his name would not provide much additional insight into the other topics connected to him. I also removed “top” because it doesn’t identify a specific news topic. I included filters for social media artifacts, such as website links and social media references, to keep the analysis focused on meaningful words.
However, I decided to keep “white” and “house” because of discussions surrounding construction at the White House, including the ballroom project. While “house” could also refer to Congress.
# STEP 1: Download the data
download.file(
url = "https://github.com/drkblake/Data/raw/refs/heads/main/Trump_story_headlines.rds",
destfile = "Trump_story_headlines.rds",
mode = "wb"
)
# STEP 2: Load the data
headlines <- readRDS("Trump_story_headlines.rds")
# STEP 3: Load the packages
library(tidytext)
library(dplyr)
library(ggplot2)
# STEP 4: Break headlines into individual words
headline_words <- headlines %>%
unnest_tokens(word, title)
# STEP 5: Look at the results
head(headline_words)
# STEP 6: Count how often each word appears
word_counts <- headline_words %>%
count(word, sort = TRUE)
# Show the 25 most common words
head(word_counts, 25)
# STEP 7: Remove stop words and Trump's name
clean_words <- headline_words %>%
anti_join(stop_words, by = "word") %>%
filter(!word %in% c(
"trump", "donald", "trump's", "trump’s"
))
# Count the remaining words
clean_counts <- clean_words %>%
count(word, sort = TRUE)
# Show all 25 most common words
print(head(clean_counts, 25), n = 25)
# STEP 8: Remove additional words and social media artifacts
excluded_words <- c(
"top",
"https", "http", "www", "amp",
"twitter", "com", "pic"
)
final_words <- clean_words %>%
filter(!word %in% excluded_words) %>%
filter(!grepl("^https|^www|^@", word))
# Count the remaining words
final_counts <- final_words %>%
count(word, sort = TRUE)
# Show the 25 most common words
print(head(final_counts, 25), n = 25)
# STEP 9: Create a bar chart of the top 25 words
top_25 <- final_counts %>%
slice_max(n, n = 25, with_ties = FALSE)
ggplot(top_25, aes(x = reorder(word, n), y = n)) +
geom_col(fill = "steelblue") +
coord_flip() +
labs(
title = "Most Common Words in Trump-Related News Headlines",
subtitle = "August 3 - October 4, 2026",
x = "Words",
y = "Number of Appearances"
) +
theme_minimal()