# Set CRAN mirror and load necessary libraries
options(repos = c(CRAN = "https://cloud.r-project.org"))
# Load necessary libraries
library(topicmodels)
library(tm)
## Loading required package: NLP
library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following object is masked from 'package:NLP':
## 
##     annotate
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(rtoot)

# Load Mastodon authentication token
auth_token <- readRDS("C:/Users/Marcus/OneDrive/Desktop/2024 WSU SEM 2/SWA/Group Project.rds")

Clustering Analysis of Political Discussions Fetching Data from Mastodon

# Fetch data related to Kamala Harris, Trump, and Election2024
kamala_posts <- get_timeline_hashtag(hashtag = "KamalaHarris", instance = "mastodon.social", limit = 1000, token = auth_token)
##   |                                                                              |                                                                      |   0%  |                                                                              |===                                                                   |   4%  |                                                                              |======                                                                |   8%  |                                                                              |=========                                                             |  12%  |                                                                              |============                                                          |  17%  |                                                                              |===============                                                       |  21%  |                                                                              |==================                                                    |  25%  |                                                                              |====================                                                  |  29%  |                                                                              |=======================                                               |  33%  |                                                                              |==========================                                            |  38%  |                                                                              |=============================                                         |  42%  |                                                                              |================================                                      |  46%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  54%  |                                                                              |=========================================                             |  58%  |                                                                              |============================================                          |  62%  |                                                                              |===============================================                       |  67%  |                                                                              |==================================================                    |  71%  |                                                                              |====================================================                  |  75%  |                                                                              |=======================================================               |  79%  |                                                                              |==========================================================            |  83%  |                                                                              |=============================================================         |  88%  |                                                                              |================================================================      |  92%  |                                                                              |===================================================================   |  96%  |                                                                              |======================================================================| 100%
trump_posts <- get_timeline_hashtag(hashtag = "Trump", instance = "mastodon.social", limit = 1000, token = auth_token)
##   |                                                                              |                                                                      |   0%  |                                                                              |===                                                                   |   4%  |                                                                              |======                                                                |   8%  |                                                                              |=========                                                             |  12%  |                                                                              |============                                                          |  17%  |                                                                              |===============                                                       |  21%  |                                                                              |==================                                                    |  25%  |                                                                              |====================                                                  |  29%  |                                                                              |=======================                                               |  33%  |                                                                              |==========================                                            |  38%  |                                                                              |=============================                                         |  42%  |                                                                              |================================                                      |  46%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  54%  |                                                                              |=========================================                             |  58%  |                                                                              |============================================                          |  62%  |                                                                              |===============================================                       |  67%  |                                                                              |==================================================                    |  71%  |                                                                              |====================================================                  |  75%  |                                                                              |=======================================================               |  79%  |                                                                              |==========================================================            |  83%  |                                                                              |=============================================================         |  88%  |                                                                              |================================================================      |  92%  |                                                                              |===================================================================   |  96%  |                                                                              |======================================================================| 100%
election_posts <- get_timeline_hashtag(hashtag = "Election2024", instance = "mastodon.social", limit = 1000, token = auth_token)
##   |                                                                              |                                                                      |   0%  |                                                                              |===                                                                   |   4%  |                                                                              |======                                                                |   8%  |                                                                              |=========                                                             |  12%  |                                                                              |============                                                          |  17%  |                                                                              |===============                                                       |  21%  |                                                                              |==================                                                    |  25%  |                                                                              |====================                                                  |  29%  |                                                                              |=======================                                               |  33%  |                                                                              |==========================                                            |  38%  |                                                                              |=============================                                         |  42%  |                                                                              |================================                                      |  46%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  54%  |                                                                              |=========================================                             |  58%  |                                                                              |============================================                          |  62%  |                                                                              |===============================================                       |  67%  |                                                                              |==================================================                    |  71%  |                                                                              |====================================================                  |  75%  |                                                                              |=======================================================               |  79%  |                                                                              |==========================================================            |  83%  |                                                                              |=============================================================         |  88%  |                                                                              |================================================================      |  92%  |                                                                              |===================================================================   |  96%  |                                                                              |======================================================================| 100%
# Combine the data into a single data frame
all_posts <- bind_rows(kamala_posts, trump_posts, election_posts)

# View the first few rows of the combined data
head(all_posts)
## # A tibble: 6 × 29
##   id         uri   created_at          content visibility sensitive spoiler_text
##   <chr>      <chr> <dttm>              <chr>   <chr>      <lgl>     <chr>       
## 1 113327704… http… 2024-10-18 09:25:31 "<p>I’… public     FALSE     ""          
## 2 113327610… http… 2024-10-18 09:01:44 "<p>Da… public     FALSE     ""          
## 3 113327563… http… 2024-10-18 08:49:54 "<p>On… public     FALSE     ""          
## 4 113327545… http… 2024-10-18 08:16:00 "Trump… public     FALSE     ""          
## 5 113327438… http… 2024-10-18 08:18:00 "<p>Co… public     FALSE     ""          
## 6 113327431… http… 2024-10-18 08:16:01 "<p>An… public     FALSE     ""          
## # ℹ 22 more variables: reblogs_count <int>, favourites_count <int>,
## #   replies_count <int>, url <chr>, in_reply_to_id <chr>,
## #   in_reply_to_account_id <chr>, language <chr>, text <lgl>,
## #   application <I<list>>, poll <I<list>>, card <I<list>>, account <list>,
## #   reblog <I<list>>, media_attachments <I<list>>, mentions <I<list>>,
## #   tags <list>, emojis <I<list>>, favourited <lgl>, reblogged <lgl>,
## #   muted <lgl>, bookmarked <lgl>, pinned <lgl>

Cleaning the Text Data

# Extract text content and create a text corpus
text_data <- all_posts$content  # Adjust if the column name is different
corpus <- VCorpus(VectorSource(text_data))

# Cleaning the text data
corpus_clean <- tm_map(corpus, content_transformer(tolower))
corpus_clean <- tm_map(corpus_clean, removePunctuation)
corpus_clean <- tm_map(corpus_clean, removeNumbers)
corpus_clean <- tm_map(corpus_clean, removeWords, stopwords("english"))
corpus_clean <- tm_map(corpus_clean, stripWhitespace)

Topic Modeling using Latent Dirichlet Allocation (LDA)

# Create a Document-Term Matrix (DTM)
dtm <- DocumentTermMatrix(corpus_clean)

# Remove sparse terms for better performance
dtm <- removeSparseTerms(dtm, 0.98)

# Perform Latent Dirichlet Allocation (LDA) to identify topics
k <- 3  # Number of topics
lda_model <- LDA(dtm, k = k, control = list(seed = 1234))

# Get the topic distributions for each document
topic_probabilities <- posterior(lda_model)$topics

Principal Component Analysis (PCA) for Dimensionality Reduction

# Perform PCA on topic probabilities
pca_res <- prcomp(topic_probabilities, center = TRUE, scale. = TRUE)

# Convert PCA results into a data frame
pca_df <- as.data.frame(pca_res$x)
pca_df$document <- rownames(pca_df)

# Assign each document the most probable topic
pca_df$assigned_topic <- as.factor(apply(topic_probabilities, 1, which.max))

Visualising the Clusters

# Visualize Clusters using PCA and ggplot2
ggplot(pca_df, aes(x = PC1, y = PC2, color = assigned_topic)) +
  geom_point(size = 3) +
  labs(title = "Clustering Analysis of Political Discussions",
       x = "Principal Component 1",
       y = "Principal Component 2",
       color = "Assigned Topic") +
  theme_minimal() +
  theme(
    plot.title = element_text(hjust = 0.5, size = 16)  # Centering and resizing the title
  ) +
  # Add custom labels for the clusters
  annotate("text", x = -1.5, y = 4, label = "Kamala Harris’s Healthcare Policies", color = "red", size = 4.5, hjust = 0) +
  annotate("text", x = 1.5, y = -1, label = "Trump’s Immigration Policies", color = "darkgreen", size = 4.5, hjust = 0) +
  annotate("text", x = 0, y = -3, label = "General Election Discussions", color = "blue", size = 4.5, hjust = 0)

# Set CRAN mirror and load necessary libraries
options(repos = c(CRAN = "https://cloud.r-project.org"))
# Load necessary libraries
library(rtoot)
library(dplyr)
library(tidyr)
library(ggplot2)

# Load Mastodon authentication token
auth_token <- readRDS("C:/Users/Marcus/OneDrive/Desktop/2024 WSU SEM 2/SWA/Group Project.rds")

Engagement Patterns Across Topics Fetching Data from Mastodon

# Fetch data for different topics: Election2024, Policy, PoliticalEvent
elections_posts <- get_timeline_hashtag(hashtag = "Election2024", instance = "mastodon.social", limit = 500, token = auth_token)
##   |                                                                              |                                                                      |   0%  |                                                                              |======                                                                |   8%  |                                                                              |============                                                          |  17%  |                                                                              |==================                                                    |  25%  |                                                                              |=======================                                               |  33%  |                                                                              |=============================                                         |  42%  |                                                                              |===================================                                   |  50%  |                                                                              |=========================================                             |  58%  |                                                                              |===============================================                       |  67%  |                                                                              |====================================================                  |  75%  |                                                                              |==========================================================            |  83%  |                                                                              |================================================================      |  92%  |                                                                              |======================================================================| 100%
policy_posts <- get_timeline_hashtag(hashtag = "Policy", instance = "mastodon.social", limit = 500, token = auth_token)
##   |                                                                              |                                                                      |   0%  |                                                                              |======                                                                |   8%  |                                                                              |============                                                          |  17%  |                                                                              |==================                                                    |  25%  |                                                                              |=======================                                               |  33%  |                                                                              |=============================                                         |  42%  |                                                                              |===================================                                   |  50%  |                                                                              |=========================================                             |  58%  |                                                                              |===============================================                       |  67%  |                                                                              |====================================================                  |  75%  |                                                                              |==========================================================            |  83%  |                                                                              |================================================================      |  92%  |                                                                              |======================================================================| 100%
events_posts <- get_timeline_hashtag(hashtag = "PoliticalEvent", instance = "mastodon.social", limit = 500, token = auth_token)
##   |                                                                              |                                                                      |   0%
# Check the column names to locate engagement metrics
colnames(elections_posts)
##  [1] "id"                     "uri"                    "created_at"            
##  [4] "content"                "visibility"             "sensitive"             
##  [7] "spoiler_text"           "reblogs_count"          "favourites_count"      
## [10] "replies_count"          "url"                    "in_reply_to_id"        
## [13] "in_reply_to_account_id" "language"               "text"                  
## [16] "application"            "poll"                   "card"                  
## [19] "account"                "reblog"                 "media_attachments"     
## [22] "mentions"               "tags"                   "emojis"                
## [25] "favourited"             "reblogged"              "muted"                 
## [28] "bookmarked"             "pinned"

Extracting Engagement Data

# Extracting engagement data for election posts
elections_engagement <- data.frame(
  topic = rep("Election", nrow(elections_posts)),
  likes = elections_posts$favourites_count,
  shares = elections_posts$reblogs_count,
  replies = elections_posts$replies_count
)

# Extracting engagement data for policy posts
policy_engagement <- data.frame(
  topic = rep("Policy", nrow(policy_posts)),
  likes = policy_posts$favourites_count,
  shares = policy_posts$reblogs_count,
  replies = policy_posts$replies_count
)

# Extracting engagement data for event posts
events_engagement <- data.frame(
  topic = rep("Event", nrow(events_posts)),
  likes = events_posts$favourites_count,
  shares = events_posts$reblogs_count,
  replies = events_posts$replies_count
)

# Combine all topics into one data frame
engagement_data <- rbind(elections_engagement, policy_engagement, events_engagement)

# Check the combined data structure
str(engagement_data)
## 'data.frame':    1043 obs. of  4 variables:
##  $ topic  : chr  "Election" "Election" "Election" "Election" ...
##  $ likes  : int  0 1 0 0 0 0 1 0 3 3 ...
##  $ shares : int  0 1 0 1 0 0 0 2 8 12 ...
##  $ replies: int  0 0 0 0 0 0 0 0 1 1 ...

Summarizing the Engagement Data

# Summarize engagement metrics by topic
engagement_summary <- engagement_data %>%
  group_by(topic) %>%
  summarize(
    avg_likes = mean(likes, na.rm = TRUE),
    avg_shares = mean(shares, na.rm = TRUE),
    avg_replies = mean(replies, na.rm = TRUE),
    total_likes = sum(likes, na.rm = TRUE),
    total_shares = sum(shares, na.rm = TRUE),
    total_replies = sum(replies, na.rm = TRUE)
  )

# View the summary
print(engagement_summary)
## # A tibble: 3 × 7
##   topic  avg_likes avg_shares avg_replies total_likes total_shares total_replies
##   <chr>      <dbl>      <dbl>       <dbl>       <int>        <int>         <int>
## 1 Elect…     3.23        5.20       0.721        1680         2705           375
## 2 Event      0.667       2.67       0.333           2            8             1
## 3 Policy     0.544       1.97       0.258         283         1024           134

Visualizing the Engagement Data Bar Plot for Average Engagement Metrics

# Bar plot for average engagement metrics by topic
ggplot(engagement_summary, aes(x = topic)) +
  geom_bar(aes(y = avg_likes), stat = "identity", fill = "blue", alpha = 0.6) +
  geom_bar(aes(y = avg_shares), stat = "identity", fill = "green", alpha = 0.6) +
  geom_bar(aes(y = avg_replies), stat = "identity", fill = "red", alpha = 0.6) +
  labs(
    title = "Average Engagement Metrics by Topic",
    x = "Topic",
    y = "Average Engagement"
  ) +
  theme_minimal()

Box Plot for Engagement Metric Distribution

# Pivot the data to long format for creating a boxplot
engagement_data_long <- pivot_longer(engagement_data, cols = c(likes, shares, replies), 
                                     names_to = "metric", values_to = "value")

# Create a box plot for engagement metric distribution by topic
ggplot(engagement_data_long, aes(x = topic, y = value, fill = metric)) +
  geom_boxplot() +
  labs(
    title = "Distribution of Engagement Metrics by Topic",
    x = "Topic",
    y = "Engagement Value"
  ) +
  theme_minimal()

```{ r child = ‘HypothesisTestingChild.rmd’}


```{ r child = 'SentimentAnalysisChild.rmd' }
# Set CRAN mirror and load necessary libraries
options(repos = c(CRAN = "https://cloud.r-project.org"))
# Load necessary libraries
library(tm)
library(wordcloud)
## Loading required package: RColorBrewer
library(RColorBrewer)
library(dplyr)
library(rtoot)

# Authenticate and load the Mastodon token
auth_token <- readRDS("C:/Users/Marcus/OneDrive/Desktop/2024 WSU SEM 2/SWA/Group Project.rds")

Sentiment Analysis for U.S. Election Topics Fetching Data Related to U.S. Election 2024

# Fetch election-related data from Mastodon
election_data <- search_accounts("U.S. election 2024")
colnames(election_data)
##  [1] "id"              "username"        "acct"            "display_name"   
##  [5] "locked"          "bot"             "discoverable"    "group"          
##  [9] "created_at"      "note"            "url"             "avatar"         
## [13] "avatar_static"   "header"          "header_static"   "followers_count"
## [17] "following_count" "statuses_count"  "last_status_at"  "fields"         
## [21] "emojis"
str(election_data)
## tibble [40 × 21] (S3: tbl_df/tbl/data.frame)
##  $ id             : chr [1:40] "109718180897393027" "110542978482163607" "109718180885037597" "110638472325896284" ...
##  $ username       : chr [1:40] "USWNT" "usopengolf" "USMNT" "usnews" ...
##  $ acct           : chr [1:40] "USWNT@sportsbots.xyz" "usopengolf@sportsbots.xyz" "USMNT@sportsbots.xyz" "usnews@beehaw.org" ...
##  $ display_name   : chr [1:40] "U.S. Women's National Soccer Team 🤖" "U.S. Open :verified_business: 🤖" "U.S. Soccer Men's National Team :verified_business: 🤖" "U.S. News" ...
##  $ locked         : logi [1:40] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ bot            : logi [1:40] TRUE TRUE TRUE FALSE FALSE FALSE ...
##  $ discoverable   : logi [1:40] TRUE TRUE TRUE FALSE FALSE TRUE ...
##  $ group          : logi [1:40] FALSE FALSE FALSE TRUE FALSE FALSE ...
##  $ created_at     : POSIXct[1:40], format: "2010-04-15" "2009-03-18" ...
##  $ note           : chr [1:40] "<p>Unofficial bot that mirrors U.S. Women's National Soccer Team’s Twitter feed.</p><p>4 x 🏆 <span class=\"h-ca"| __truncated__ "<p>Unofficial bot that mirrors U.S. Open’s Twitter feed.</p><p>The official handle of the <span class=\"h-card\"| __truncated__ "<p>Unofficial bot that mirrors U.S. Soccer Men's National Team’s Twitter feed.</p><p>⚽️🇺🇸</p>" "<p>News about and pertaining to the United States and its people.</p>\n<p>Please read <a href=\"https://beehaw."| __truncated__ ...
##  $ url            : chr [1:40] "https://sportsbots.xyz/users/USWNT" "https://sportsbots.xyz/users/usopengolf" "https://sportsbots.xyz/users/USMNT" "https://beehaw.org/c/usnews" ...
##  $ avatar         : chr [1:40] "https://files.mastodon.social/cache/accounts/avatars/109/718/180/897/393/027/original/9a257a5f3baf428e.jpg" "https://files.mastodon.social/cache/accounts/avatars/110/542/978/482/163/607/original/93aafc8e0f9b8276.jpg" "https://files.mastodon.social/cache/accounts/avatars/109/718/180/885/037/597/original/b87ff36766285974.jpg" "https://files.mastodon.social/cache/accounts/avatars/110/638/472/325/896/284/original/39d999953beaf9c6.png" ...
##  $ avatar_static  : chr [1:40] "https://files.mastodon.social/cache/accounts/avatars/109/718/180/897/393/027/original/9a257a5f3baf428e.jpg" "https://files.mastodon.social/cache/accounts/avatars/110/542/978/482/163/607/original/93aafc8e0f9b8276.jpg" "https://files.mastodon.social/cache/accounts/avatars/109/718/180/885/037/597/original/b87ff36766285974.jpg" "https://files.mastodon.social/cache/accounts/avatars/110/638/472/325/896/284/original/39d999953beaf9c6.png" ...
##  $ header         : chr [1:40] "https://mastodon.social/headers/original/missing.png" "https://mastodon.social/headers/original/missing.png" "https://mastodon.social/headers/original/missing.png" "https://mastodon.social/headers/original/missing.png" ...
##  $ header_static  : chr [1:40] "https://mastodon.social/headers/original/missing.png" "https://mastodon.social/headers/original/missing.png" "https://mastodon.social/headers/original/missing.png" "https://mastodon.social/headers/original/missing.png" ...
##  $ followers_count: int [1:40] 2470000 511000 2330001 2118 35648 14899 135391 6265 534 208 ...
##  $ following_count: int [1:40] 200 600 200 0 676 0 5 1 210 167 ...
##  $ statuses_count : int [1:40] 1419 215 844 1690 2017 34998 14619 4829 11951 13294 ...
##  $ last_status_at : POSIXct[1:40], format: NA NA ...
##  $ fields         :List of 40
##   ..$ : tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:4] "Twitter" "Website" "Managed by" "Retention"
##   .. ..$ value: chr [1:4] "<a href=\"https://twitter.com/USWNT\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invi"| __truncated__ "<a href=\"https://ussoc.cr/uswnt\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisib"| __truncated__ "<span class=\"h-card\"><a href=\"https://mastodon.social/@sportsbots\" class=\"u-url mention\" rel=\"nofollow n"| __truncated__ "<span class=\"h-card\">90 days</span>"
##   ..$ : tibble [5 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:5] "Twitter" "Twitter Verified" "Website" "Managed by" ...
##   .. ..$ value: chr [1:5] "<a href=\"https://twitter.com/usopengolf\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"| __truncated__ "Business" "<a href=\"https://www.usopen.com\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisib"| __truncated__ "<span class=\"h-card\"><a href=\"https://mastodon.social/@sportsbots\" class=\"u-url mention\" rel=\"nofollow n"| __truncated__ ...
##   ..$ : tibble [5 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:5] "Twitter" "Twitter Verified" "Website" "Managed by" ...
##   .. ..$ value: chr [1:5] "<a href=\"https://twitter.com/USMNT\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invi"| __truncated__ "Business" "<a href=\"https://ussoc.cr/usmnt\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisib"| __truncated__ "<span class=\"h-card\"><a href=\"https://mastodon.social/@sportsbots\" class=\"u-url mention\" rel=\"nofollow n"| __truncated__ ...
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Operated by"
##   .. ..$ value: chr "<span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.social/@cybermancy\" class=\"u-url mention\""| __truncated__
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Website"
##   .. ..$ value: chr "<a href=\"https://electiongraphs.com/\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\""| __truncated__
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@NewsLitProject\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target="| __truncated__ "<a href=\"https://flipboard.com/@newslitproject/2024-presidential-election-misinformation-43m0ge27z\" rel=\"nof"| __truncated__
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "めっちゃかわいい神師匠(" "かわいい師匠()"
##   .. ..$ value: chr [1:2] "@Kirakirasann@oran.ski" "@haitani_waka0824@oran.ski"
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "身份认同" "内容"
##   .. ..$ value: chr [1:2] "女巫" "努力活着,骂骂男的,骂骂世界,磕磕CP,梦想一夜暴富"
##   ..$ : tibble [4 × 3] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name       : chr [1:4] "Website" "Newsletters" "About us" "Support our work"
##   .. ..$ value      : chr [1:4] "<a href=\"https://theconversation.com/us\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"n"| __truncated__ "<a href=\"https://theconversation.com/us/newsletters/subscribe/?promoted=daily-newsletter-3\" target=\"_blank\""| __truncated__ "<a href=\"https://theconversation.com/us/who-we-are\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" tr"| __truncated__ "<a href=\"https://donate.theconversation.com/us?utm_source=mastodon&amp;amp;utm_medium=Social\" rel=\"nofollow "| __truncated__
##   .. ..$ verified_at: chr [1:4] "2024-10-17T23:21:56.888+00:00" "2024-10-17T23:21:57.117+00:00" "2024-10-17T23:21:57.146+00:00" NA
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@ElectionCentral\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target"| __truncated__ "<a href=\"https://flipboard.com/@electioncentral/2024-white-house-011m28mnz\" rel=\"nofollow noopener noreferre"| __truncated__
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@AxiosNews\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_bl"| __truncated__ "<a href=\"https://flipboard.com/@axiosnews/2024-elections-0vnr9lr8z\" rel=\"nofollow noopener noreferrer\" tran"| __truncated__
##   ..$ : list()
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "日常" "阅读" "目标"
##   .. ..$ value: chr [1:3] "读书和碎碎念" "偏好类型小说,乙一、京极及伊坂为心头好" "向600本迈进~(529/600)"
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Owner" "Twitter Relay"
##   .. ..$ value: chr [1:2] "<span class=\"h-card\"><a href=\"https://noagendasocial.com/@commandlinekid\" class=\"u-url mention\" rel=\"nof"| __truncated__ "<a href=\"https://twitter.com/CENTCOM\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"in"| __truncated__
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "Twitter" "Bluesky" "Discord"
##   .. ..$ value: chr [1:3] "<a href=\"https://twitter.com/ItsMeKaidinn\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_bl"| __truncated__ "Kaidinn" "Kaidinn"
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@npr\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\">"| __truncated__ "<a href=\"https://flipboard.com/@npr/u.s.-news-aspd61boz\" rel=\"nofollow noopener noreferrer\" translate=\"no\"| __truncated__
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@CBSNews\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blan"| __truncated__ "<a href=\"https://flipboard.com/@cbsnews/u.s.-news-b4dbunnmz\" rel=\"nofollow noopener noreferrer\" translate=\"| __truncated__
##   ..$ : tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:4] "‼" "💯" "🐧" "⚠️"
##   .. ..$ value: chr [1:4] "对人类一无所知 性别意识弱 只能先默认大家都是史莱姆" "pan :heart_pan: genderfluid :blobcatgenderfluid: 暴躁酷儿🔥支持海盗党🆓支持0个中国🏴‍☠️" "they/佢/she" "极易不安 躁郁+焦虑治疗中 可能是神经非典型"
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Pronouns"
##   .. ..$ value: chr "Anything you like/they/them"
##   ..$ : tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:4] "Personal Website" "UF Website" "LinkedIn" "Twitter"
##   .. ..$ value: chr [1:4] "www.electionsmith.com/" "polisci.ufl.edu/daniel-a-smith/" "www.linkedin.com/in/electionsmith/" "<span class=\"h-card\" translate=\"no\"><a href=\"https://sciences.social/@Electionsmith\" class=\"u-url mentio"| __truncated__
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@AssociatedPress\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target"| __truncated__ "<a href=\"https://flipboard.com/@associatedpress/u.s.-news-lhl4uphvz\" rel=\"nofollow noopener noreferrer\" tra"| __truncated__
##   ..$ : tibble [3 × 3] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name       : chr [1:3] "Webseite" "Datum" "Ort"
##   .. ..$ value      : chr [1:3] "<a href=\"https://eh21.easterhegg.eu\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"no\">"| __truncated__ "29.3.24.-1.4.24" "OTH Regensburg, Gebäude K + D/E, 93053 Regensburg Galgenbergstr. 30 + 32"
##   .. ..$ verified_at: chr [1:3] "2024-07-21T17:36:38.078+00:00" NA NA
##   ..$ : list()
##   ..$ : tibble [3 × 3] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name       : chr [1:3] "🔗 Web" "🐦 Twitter" "🎮Discord"
##   .. ..$ value      : chr [1:3] "<a href=\"https://notgdc.io\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"no\"><span cla"| __truncated__ "<a href=\"https://twitter.com/notgdc\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\">"| __truncated__ "<a href=\"https://discord.notgdc.io\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><"| __truncated__
##   .. ..$ verified_at: chr [1:3] "2024-04-13T18:51:55.601+00:00" NA NA
##   ..$ : list()
##   ..$ : list()
##   ..- attr(*, "class")= chr "AsIs"
##  $ emojis         :List of 40
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "verified_business"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/512/920/original/23a3b761db06ee08.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/512/920/static/23a3b761db06ee08.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "verified_business"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/512/920/original/23a3b761db06ee08.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/512/920/static/23a3b761db06ee08.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "blobcatphoto"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/208/083/original/25f65a25b2d9a93a.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/208/083/static/25f65a25b2d9a93a.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "neocat_yeet"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/809/075/original/174e3458393244de.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/809/075/static/174e3458393244de.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "acat"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/213/920/original/da973b99e73271b0.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/213/920/static/da973b99e73271b0.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "monsterenergy"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/700/561/original/e8ccf9ea42fb64fc.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/700/561/static/e8ccf9ea42fb64fc.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [2 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr [1:2] "heart_pan" "blobcatgenderfluid"
##   .. ..$ url              : chr [1:2] "https://files.mastodon.social/cache/custom_emojis/images/000/214/738/original/6d46f7fa9c9e642a.png" "https://files.mastodon.social/cache/custom_emojis/images/000/392/068/original/d8cc111940c51ec0.png"
##   .. ..$ static_url       : chr [1:2] "https://files.mastodon.social/cache/custom_emojis/images/000/214/738/static/6d46f7fa9c9e642a.png" "https://files.mastodon.social/cache/custom_emojis/images/000/392/068/static/d8cc111940c51ec0.png"
##   .. ..$ visible_in_picker: logi [1:2] TRUE TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..- attr(*, "class")= chr "AsIs"
##  - attr(*, "headers")= tibble [1 × 3] (S3: tbl_df/tbl/data.frame)
##   ..$ rate_limit    : chr "300"
##   ..$ rate_remaining: chr "299"
##   ..$ rate_reset    : POSIXlt[1:1], format: "2024-10-18 09:35:00"

Preprocessing Text Data for Word Cloud

# Create and clean content corpus
corpus <- Corpus(VectorSource(election_data$note))  # Assuming 'note' column has the content

corpus <- tm_map(corpus, content_transformer(tolower))  # Convert to lowercase
## Warning in tm_map.SimpleCorpus(corpus, content_transformer(tolower)):
## transformation drops documents
corpus <- tm_map(corpus, removePunctuation)  # Remove punctuation
## Warning in tm_map.SimpleCorpus(corpus, removePunctuation): transformation drops
## documents
corpus <- tm_map(corpus, removeNumbers)  # Remove numbers
## Warning in tm_map.SimpleCorpus(corpus, removeNumbers): transformation drops
## documents
# Customize stopwords to avoid removing key election terms
custom_stopwords <- setdiff(stopwords("english"), c("election", "vote", "campaign", "trump", "harris"))
corpus <- tm_map(corpus, removeWords, custom_stopwords)
## Warning in tm_map.SimpleCorpus(corpus, removeWords, custom_stopwords):
## transformation drops documents
corpus <- tm_map(corpus, stripWhitespace)  # Remove extra whitespace
## Warning in tm_map.SimpleCorpus(corpus, stripWhitespace): transformation drops
## documents

Word Cloud for U.S. Election

# Create Document-Term Matrix
dtm <- TermDocumentMatrix(corpus)
matrix <- as.matrix(dtm)

# Calculate word frequencies
word_freqs <- sort(rowSums(matrix), decreasing = TRUE)
word_freqs_df <- data.frame(word = names(word_freqs), freq = word_freqs)

# Set color palette and generate the word cloud
palette <- brewer.pal(8, "Dark2")
set.seed(1234)
wordcloud(words = word_freqs_df$word, freq = word_freqs_df$freq, min.freq = 2, max.words = 500, random.order = FALSE, rot.per = 0.35, colors = palette)

# Add title
title(main = "Dominant U.S. Election Topics 2024", col.main = "blue", font.main = 4, cex.main = 1.5)

Donald Trump Word Cloud

# Fetch and preprocess Trump-related data
trump_data <- search_accounts("trump")
colnames(trump_data)
##  [1] "id"              "username"        "acct"            "display_name"   
##  [5] "locked"          "bot"             "discoverable"    "group"          
##  [9] "created_at"      "note"            "url"             "avatar"         
## [13] "avatar_static"   "header"          "header_static"   "followers_count"
## [17] "following_count" "statuses_count"  "last_status_at"  "fields"         
## [21] "emojis"
str(trump_data)
## tibble [40 × 21] (S3: tbl_df/tbl/data.frame)
##  $ id             : chr [1:40] "46932" "776757" "106361622292705007" "110629704140119046" ...
##  $ username       : chr [1:40] "Trump" "trumpet" "whataboob" "Trump" ...
##  $ acct           : chr [1:40] "Trump@mastodon.xyz" "trumpet@mas.to" "whataboob@noagendasocial.com" "Trump@femboys.love" ...
##  $ display_name   : chr [1:40] "Donald J. Trump ✅" "trumpet@mas.to" "Trump Won 2020" "Donald Trump" ...
##  $ locked         : logi [1:40] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ bot            : logi [1:40] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ discoverable   : logi [1:40] FALSE TRUE FALSE FALSE TRUE FALSE ...
##  $ group          : logi [1:40] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ created_at     : POSIXct[1:40], format: "2017-04-04" "2019-03-28" ...
##  $ note           : chr [1:40] "<p>45th President of the United States of America (Tweets are obviously parody)</p>" "<p>Hello! I'm the mas.to administrator account.</p>" "<p>My pronouns are “Trump Won.”  Covfefe cult member 🇺🇸  You’re the puppet. If money is the root of all evil, w"| __truncated__ "45th President of the United States of America🇺🇸" ...
##  $ url            : chr [1:40] "https://mastodon.xyz/@Trump" "https://mas.to/@trumpet" "https://noagendasocial.com/@whataboob" "https://femboys.love/users/Trump" ...
##  $ avatar         : chr [1:40] "https://files.mastodon.social/accounts/avatars/000/046/932/original/c2d2cfc56128c98b.jpg" "https://files.mastodon.social/cache/accounts/avatars/000/776/757/original/973c7ae4796a13ff.png" "https://files.mastodon.social/cache/accounts/avatars/106/361/622/292/705/007/original/27376dc4d85aea30.jpeg" "https://files.mastodon.social/cache/accounts/avatars/110/629/704/140/119/046/original/0305bcc4347126d2.jpg" ...
##  $ avatar_static  : chr [1:40] "https://files.mastodon.social/accounts/avatars/000/046/932/original/c2d2cfc56128c98b.jpg" "https://files.mastodon.social/cache/accounts/avatars/000/776/757/original/973c7ae4796a13ff.png" "https://files.mastodon.social/cache/accounts/avatars/106/361/622/292/705/007/original/27376dc4d85aea30.jpeg" "https://files.mastodon.social/cache/accounts/avatars/110/629/704/140/119/046/original/0305bcc4347126d2.jpg" ...
##  $ header         : chr [1:40] "https://mastodon.social/headers/original/missing.png" "https://files.mastodon.social/cache/accounts/headers/000/776/757/original/5834b495d1ad7a52.png" "https://files.mastodon.social/cache/accounts/headers/106/361/622/292/705/007/original/8a4cffc49c39ee87.jpeg" "https://files.mastodon.social/cache/accounts/headers/110/629/704/140/119/046/original/e35dffc20f440d8b.jpg" ...
##  $ header_static  : chr [1:40] "https://mastodon.social/headers/original/missing.png" "https://files.mastodon.social/cache/accounts/headers/000/776/757/original/5834b495d1ad7a52.png" "https://files.mastodon.social/cache/accounts/headers/106/361/622/292/705/007/original/8a4cffc49c39ee87.jpeg" "https://files.mastodon.social/cache/accounts/headers/110/629/704/140/119/046/original/e35dffc20f440d8b.jpg" ...
##  $ followers_count: int [1:40] 809 38629 238 70 7786 139 124 340 495 500 ...
##  $ following_count: int [1:40] 0 0 150 27 0 574 0 11 33 48 ...
##  $ statuses_count : int [1:40] 53 2197 2555 14 1056 1765 1091 534 10 762 ...
##  $ last_status_at : POSIXct[1:40], format: NA NA ...
##  $ fields         :List of 40
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Admin" "Donate"
##   .. ..$ value: chr [1:2] "<a href=\"http://mas.to/\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><span class="| __truncated__ "<a href=\"https://ko-fi.com/trumpet\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><"| __truncated__
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Here Is The Evidence" "Election Fraud Videos"
##   .. ..$ value: chr [1:2] "<a href=\"https://hereistheevidence.com\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank"| __truncated__ "<a href=\"https://odysee.com/@Trump_Won_2020:b\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"| __truncated__
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Admin" "Donate"
##   .. ..$ value: chr [1:2] "<a href=\"http://mastodon.scot\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><span "| __truncated__ "<a href=\"https://ko-fi.com/trumpet\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><"| __truncated__
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@ElectionCentral\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target"| __truncated__ "<a href=\"https://flipboard.com/@electioncentral/trump-legal-issues-8b7bnctqz\" rel=\"nofollow noopener norefer"| __truncated__
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Website"
##   .. ..$ value: chr "<a href=\"https://www.Trumpbert.com\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><"| __truncated__
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Twitter"
##   .. ..$ value: chr "<span class=\"h-card\" translate=\"no\"><a href=\"https://mastodon.world/@TrumpsTaxes\" class=\"u-url mention\""| __truncated__
##   ..$ : list()
##   ..$ : tibble [4 × 3] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name       : chr [1:4] "Pixelfed" "Twitter" "Gitlab" "GOL / Wiki"
##   .. ..$ value      : chr [1:4] "<a href=\"https://pixelfed.social/Trumpy\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate="| __truncated__ "<a href=\"https://twitter.com/trump_onlinux\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" transla"| __truncated__ "<a href=\"https://gitlab.com/Trump\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no\""| __truncated__ "<a href=\"https://www.gamingonlinux.com/wiki/\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" trans"| __truncated__
##   .. ..$ verified_at: chr [1:4] "2018-10-22T10:41:56.896+00:00" NA NA NA
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Also"
##   .. ..$ value: chr "<span class=\"h-card\"><a href=\"https://quey.org/@DonaldTrump\" class=\"u-url mention\" rel=\"nofollow noopene"| __truncated__
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Owner" "Twitter Relay"
##   .. ..$ value: chr [1:2] "<span class=\"h-card\"><a href=\"https://noagendasocial.com/@commandlinekid\" class=\"u-url mention\" rel=\"nof"| __truncated__ "<a href=\"https://twitter.com/realdonaldtrump\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span cl"| __truncated__
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "allmylinks.com" "Birthday" "Pronouns"
##   .. ..$ value: chr [1:3] "<a href=\"https://allmylinks.com/trumpy303\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_bl"| __truncated__ "December 5 1980" "He/Him"
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "what?"
##   .. ..$ value: chr "this is a fake account, acting as a bridge to a real twitter account. You cannot follow it, only the developer can"
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [4 × 3] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name       : chr [1:4] "Star ..." "Pronouns" "Grid loc/TZ" "Website"
##   .. ..$ value      : chr [1:4] "Trek" "He/Him" "FN25sn/UTC-5(-4 summer)" "<a href=\"https://underwateryagi.blogspot.com\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translat"| __truncated__
##   .. ..$ verified_at: chr [1:4] NA NA NA "2024-10-17T02:42:37.283+00:00"
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Twitter" "Status"
##   .. ..$ value: chr [1:2] "<a href=\"https://www.twitter.com/@Trump_Chinese\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span"| __truncated__ "Cross-Site-Subscribed account: unclaimed"
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "About"
##   .. ..$ value: chr "Parody."
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Owner" "Twitter Relay"
##   .. ..$ value: chr [1:2] "<span class=\"h-card\"><a href=\"https://noagendasocial.com/@commandlinekid\" class=\"u-url mention\" rel=\"nof"| __truncated__ "<a href=\"https://twitter.com/DonaldJTrumpJr\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span cla"| __truncated__
##   ..$ : list()
##   ..$ : list()
##   ..- attr(*, "class")= chr "AsIs"
##  $ emojis         :List of 40
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "verified"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/230/165/original/702d12855bd2af2a.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/230/165/static/702d12855bd2af2a.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "elonmusk"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/446/208/original/3088dd29d228530b.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/446/208/static/3088dd29d228530b.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..- attr(*, "class")= chr "AsIs"
##  - attr(*, "headers")= tibble [1 × 3] (S3: tbl_df/tbl/data.frame)
##   ..$ rate_limit    : chr "300"
##   ..$ rate_remaining: chr "298"
##   ..$ rate_reset    : POSIXlt[1:1], format: "2024-10-18 09:35:00"
corpus_trump <- Corpus(VectorSource(trump_data$note))
corpus_trump <- tm_map(corpus_trump, content_transformer(tolower))
## Warning in tm_map.SimpleCorpus(corpus_trump, content_transformer(tolower)):
## transformation drops documents
corpus_trump <- tm_map(corpus_trump, removePunctuation)
## Warning in tm_map.SimpleCorpus(corpus_trump, removePunctuation): transformation
## drops documents
corpus_trump <- tm_map(corpus_trump, removeNumbers)
## Warning in tm_map.SimpleCorpus(corpus_trump, removeNumbers): transformation
## drops documents
corpus_trump <- tm_map(corpus_trump, removeWords, stopwords("english"))
## Warning in tm_map.SimpleCorpus(corpus_trump, removeWords,
## stopwords("english")): transformation drops documents
corpus_trump <- tm_map(corpus_trump, stripWhitespace)
## Warning in tm_map.SimpleCorpus(corpus_trump, stripWhitespace): transformation
## drops documents
# Create DTM and generate word cloud
dtm_trump <- TermDocumentMatrix(corpus_trump)
matrix_trump <- as.matrix(dtm_trump)
word_freqs_trump <- sort(rowSums(matrix_trump), decreasing = TRUE)
word_freqs_trump_df <- data.frame(word = names(word_freqs_trump), freq = word_freqs_trump)

set.seed(1234)
wordcloud(words = word_freqs_trump_df$word, freq = word_freqs_trump_df$freq, min.freq = 2, max.words = 500, random.order = FALSE, rot.per = 0.35, colors = palette)

title(main = "Topics Related to Donald Trump", col.main = "blue", font.main = 4, cex.main = 1.5)

Kamala Harris Word Cloud

# Fetch and preprocess Kamala Harris-related data
kamala_data <- search_accounts("kamala")
colnames(kamala_data)
##  [1] "id"              "username"        "acct"            "display_name"   
##  [5] "locked"          "bot"             "discoverable"    "group"          
##  [9] "created_at"      "note"            "url"             "avatar"         
## [13] "avatar_static"   "header"          "header_static"   "followers_count"
## [17] "following_count" "statuses_count"  "last_status_at"  "fields"         
## [21] "emojis"
str(kamala_data)
## tibble [40 × 21] (S3: tbl_df/tbl/data.frame)
##  $ id             : chr [1:40] "112998997991835175" "109346300885974284" "112923530880018505" "110839218522424243" ...
##  $ username       : chr [1:40] "KamalaHarrisWin" "Kamala_Rao" "swifties4kamala" "kamala" ...
##  $ acct           : chr [1:40] "KamalaHarrisWin@newsmast.social" "Kamala_Rao@ioc.exchange" "swifties4kamala@threads.net" "kamala@masto.es" ...
##  $ display_name   : chr [1:40] "Kamala Harris News Group 2.0" "Kamala Rao" "Swifties For Kamala" ":heart_poly:  :bh_flag_nonbinary:" ...
##  $ locked         : logi [1:40] TRUE FALSE FALSE FALSE FALSE TRUE ...
##  $ bot            : logi [1:40] TRUE FALSE FALSE FALSE FALSE FALSE ...
##  $ discoverable   : logi [1:40] TRUE TRUE FALSE TRUE FALSE FALSE ...
##  $ group          : logi [1:40] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ created_at     : POSIXct[1:40], format: "2024-08-21" "2022-11-15" ...
##  $ note           : chr [1:40] "<p>Kamala Harris News &amp; Organizing Group - 2.0</p><p>A public group for discussion of news and pro-Harris o"| __truncated__ "<p>Interests and involvements include: journalism, labour organizing, feminism, 🏳️‍🌈, wellness, wilderness, famil"| __truncated__ "<p>Coalition of Swifties mobilizing Taylor Swift fans to get progressive candidates elected up &amp; down the b"| __truncated__ "<p>Nunca se es lo suficientemente woke. No me gusta la fruta.</p><p>Sueño con pasarme a un móvil llama-escribe;"| __truncated__ ...
##  $ url            : chr [1:40] "https://newsmast.social/@KamalaHarrisWin" "https://ioc.exchange/@Kamala_Rao" "https://threads.net/@swifties4kamala/" "https://masto.es/@kamala" ...
##  $ avatar         : chr [1:40] "https://files.mastodon.social/cache/accounts/avatars/112/998/997/991/835/175/original/a36dc4fc1496f879.png" "https://files.mastodon.social/cache/accounts/avatars/109/346/300/885/974/284/original/80d98aab161ed3dd.jpeg" "https://files.mastodon.social/cache/accounts/avatars/112/923/530/880/018/505/original/43b366648ff96367.jpg" "https://files.mastodon.social/cache/accounts/avatars/110/839/218/522/424/243/original/d13f4c5e864469dd.jpg" ...
##  $ avatar_static  : chr [1:40] "https://files.mastodon.social/cache/accounts/avatars/112/998/997/991/835/175/original/a36dc4fc1496f879.png" "https://files.mastodon.social/cache/accounts/avatars/109/346/300/885/974/284/original/80d98aab161ed3dd.jpeg" "https://files.mastodon.social/cache/accounts/avatars/112/923/530/880/018/505/original/43b366648ff96367.jpg" "https://files.mastodon.social/cache/accounts/avatars/110/839/218/522/424/243/original/d13f4c5e864469dd.jpg" ...
##  $ header         : chr [1:40] "https://files.mastodon.social/cache/accounts/headers/112/998/997/991/835/175/original/ea8a6f3fff493f7e.png" "https://files.mastodon.social/cache/accounts/headers/109/346/300/885/974/284/original/ab4e6cffe5dbd376.jpeg" "https://mastodon.social/headers/original/missing.png" "https://files.mastodon.social/cache/accounts/headers/110/839/218/522/424/243/original/1b19f7a0858cd19d.jpg" ...
##  $ header_static  : chr [1:40] "https://files.mastodon.social/cache/accounts/headers/112/998/997/991/835/175/original/ea8a6f3fff493f7e.png" "https://files.mastodon.social/cache/accounts/headers/109/346/300/885/974/284/original/ab4e6cffe5dbd376.jpeg" "https://mastodon.social/headers/original/missing.png" "https://files.mastodon.social/cache/accounts/headers/110/839/218/522/424/243/original/1b19f7a0858cd19d.jpg" ...
##  $ followers_count: int [1:40] 3186 70 31036 45 103195 1658 691 16 7292 807 ...
##  $ following_count: int [1:40] 5017 151 210 54 475 2526 238 7 600 816 ...
##  $ statuses_count : int [1:40] 12891 104 2194 63 4363 208 1779 4 2424 305 ...
##  $ last_status_at : POSIXct[1:40], format: NA NA ...
##  $ fields         :List of 40
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "The official 2.0 Account for Kamala Harris News and Organizing" "Mastodon for Harris Giving" "Support docs for this group:"
##   .. ..$ value: chr [1:3] "Was formerly Kamala Harris Friendica Group" "<a href=\"https://secure.actblue.com/donate/mastodon-for-harris\" rel=\"nofollow noopener noreferrer\" translat"| __truncated__ "<a href=\"https://kamalaharrisnewsandorganizing.simple.ink/\" rel=\"nofollow noopener noreferrer\" translate=\""| __truncated__
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "Twitter" "Post" "Location"
##   .. ..$ value: chr [1:3] "<a href=\"https://twitter.com/kam_rao\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\""| __truncated__ "<a href=\"https://post.news/kamala_rao\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"| __truncated__ "Toronto"
##   ..$ : list()
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "🪪PRONOUNS" "🗣️" "Leyendo"
##   .. ..$ value: chr [1:3] "They/He" "ESP/EUS/ENG" "La aventura del tocador de señoras - Eduardo Mendoza"
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "column" "thiral" "coopon"
##   .. ..$ value: chr [1:3] "<a href=\"https://gitlab.com/demonshreder/column\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target"| __truncated__ "<a href=\"https://gitlab.com/demonshreder/thiral\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target"| __truncated__ "<a href=\"https://wiki.cooponscitech.in/\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blan"| __truncated__
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:4] "pronouns" "Equality, and also" "Website" "Catalog/Shop"
##   .. ..$ value: chr [1:4] "she/her" "fine arts, science, nerdery, gardening, birds and bugs" "<a href=\"https://www.blupastels.com\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\">"| __truncated__ "<a href=\"https://www.dailypaintworks.com/Artists/tamami-tokutake-9779\" rel=\"nofollow noopener noreferrer\" t"| __truncated__
##   ..$ : tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:4] "Friendship, Effort, Victory" "Twitch" "Youtube" "Reddit"
##   .. ..$ value: chr [1:4] "<a href=\"https://www.drivethrurpg.com/product/383807/Friendship-Effort-Victory\" rel=\"nofollow noopener noref"| __truncated__ "<a href=\"https://www.twitch.tv/plato_of_athens\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target="| __truncated__ "<a href=\"https://www.youtube.com/channel/UCR2LOhyz-z15L8rQCKUAXLw\" rel=\"nofollow noopener noreferrer\" trans"| __truncated__ "<a href=\"https://www.reddit.com/user/Josh_From_Accounting\" rel=\"nofollow noopener noreferrer\" translate=\"n"| __truncated__
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Banner #altText" "Profile #altText"
##   .. ..$ value: chr [1:2] "Propeller engine at an automotive museum in Maine" "Closeup of pale female face with short blond hair and dark framed glasses"
##   ..$ : list()
##   ..$ : tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:4] "Permaculture Activist / HeartBeet Farm" "Permaculture Design Magazine" "LinkedIn" "Facebook"
##   .. ..$ value: chr [1:4] "<a href=\"https://permacultureactivist.net/\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_b"| __truncated__ "<a href=\"https://www.permaculturedesignmagazine.com/\" rel=\"nofollow noopener noreferrer\" translate=\"no\" t"| __truncated__ "<a href=\"https://www.linkedin.com/in/keith-johnson-51a08417/\" rel=\"nofollow noopener noreferrer\" translate="| __truncated__ "<a href=\"https://www.facebook.com/keith.d.johnson2\" rel=\"nofollow noopener noreferrer\" translate=\"no\" tar"| __truncated__
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [4 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:4] "📷" "🎥" "📰" "🏄‍♀️"
##   .. ..$ value: chr [1:4] "" "" "" ""
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Flipboard" "Magazine"
##   .. ..$ value: chr [1:2] "<a href=\"https://flipboard.com/@AxiosNews\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_bl"| __truncated__ "<a href=\"https://flipboard.com/@axiosnews/kamala-harris-91tkvfi9z\" rel=\"nofollow noopener noreferrer\" trans"| __truncated__
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "About"
##   .. ..$ value: chr "Democracy, dogs, knitting"
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "Wohnort" "Geburtstag" "Nur meine Beiträge"
##   .. ..$ value: chr [1:3] "Ruhrgebiet" "17.04." "<a href=\"https://justmytoots.com/@bilchi@nrw.social\" rel=\"nofollow noopener noreferrer\" translate=\"no\" ta"| __truncated__
##   ..$ : tibble [4 × 3] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name       : chr [1:4] "Pronouns" "Blog" "Banner" "Icon/Avatar"
##   .. ..$ value      : chr [1:4] "She/Her" "<a href=\"https://rachelthorn.net\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" translate=\"no\"><sp"| __truncated__ "Illustration by Moto Hagio featuring characters from her comic, \"The Poe Clan\"" "Recent selfie of me in a leather biker jacket looking at the viewer. I have gray hair in a bob style. Not smili"| __truncated__
##   .. ..$ verified_at: chr [1:4] NA "2024-10-17T14:25:05.089+00:00" NA NA
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Threads"
##   .. ..$ value: chr "<a href=\"https://threads.net/@vp\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><sp"| __truncated__
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Twitter"
##   .. ..$ value: chr "<a href=\"https://fedified.com/@unabogie\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blan"| __truncated__
##   ..$ : tibble [3 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:3] "he/him" "Interests" "Share all your dog pics"
##   .. ..$ value: chr [1:3] "" "LA Metro enthusiast, basketball bro, ebiker, dog lover, LGBT+ supporter" ""
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "App" "birdsite"
##   .. ..$ value: chr [1:2] "<a href=\"https://play.google.com/store/apps/details?id=org.simuladorelecciones.ar\" target=\"_blank\" rel=\"no"| __truncated__ "<a href=\"https://x.com/kamalavtrump\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\" translate=\"no"| __truncated__
##   ..$ : list()
##   ..$ : tibble [2 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr [1:2] "Dotter + Pop" "More About Me"
##   .. ..$ value: chr [1:2] "<a href=\"https://dotterandpop.com\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\"><s"| __truncated__ "<a href=\"https://linktr.ee/ericsfeed\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_blank\""| __truncated__
##   ..$ : tibble [1 × 2] (S3: tbl_df/tbl/data.frame)
##   .. ..$ name : chr "Website"
##   .. ..$ value: chr "<a href=\"https://nitter.poast.org/KamalaHQ\" rel=\"nofollow noopener noreferrer\" translate=\"no\" target=\"_b"| __truncated__
##   ..- attr(*, "class")= chr "AsIs"
##  $ emojis         :List of 40
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [2 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr [1:2] "heart_poly" "bh_flag_nonbinary"
##   .. ..$ url              : chr [1:2] "https://files.mastodon.social/cache/custom_emojis/images/000/627/592/original/7f035f93c5881bee.png" "https://files.mastodon.social/cache/custom_emojis/images/000/687/100/original/4415b1bedc0113ab.png"
##   .. ..$ static_url       : chr [1:2] "https://files.mastodon.social/cache/custom_emojis/images/000/627/592/static/7f035f93c5881bee.png" "https://files.mastodon.social/cache/custom_emojis/images/000/687/100/static/4415b1bedc0113ab.png"
##   .. ..$ visible_in_picker: logi [1:2] TRUE TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "fckafd"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/829/193/original/ace551ece247eb35.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/829/193/static/ace551ece247eb35.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : list()
##   ..$ : tibble [1 × 4] (S3: tbl_df/tbl/data.frame)
##   .. ..$ shortcode        : chr "warriors"
##   .. ..$ url              : chr "https://files.mastodon.social/cache/custom_emojis/images/000/469/530/original/b5e508f5a2680338.png"
##   .. ..$ static_url       : chr "https://files.mastodon.social/cache/custom_emojis/images/000/469/530/static/b5e508f5a2680338.png"
##   .. ..$ visible_in_picker: logi TRUE
##   ..$ : list()
##   ..- attr(*, "class")= chr "AsIs"
##  - attr(*, "headers")= tibble [1 × 3] (S3: tbl_df/tbl/data.frame)
##   ..$ rate_limit    : chr "300"
##   ..$ rate_remaining: chr "297"
##   ..$ rate_reset    : POSIXlt[1:1], format: "2024-10-18 09:35:00"
corpus_kamala <- Corpus(VectorSource(kamala_data$note))
corpus_kamala <- tm_map(corpus_kamala, content_transformer(tolower))
## Warning in tm_map.SimpleCorpus(corpus_kamala, content_transformer(tolower)):
## transformation drops documents
corpus_kamala <- tm_map(corpus_kamala, removePunctuation)
## Warning in tm_map.SimpleCorpus(corpus_kamala, removePunctuation):
## transformation drops documents
corpus_kamala <- tm_map(corpus_kamala, removeNumbers)
## Warning in tm_map.SimpleCorpus(corpus_kamala, removeNumbers): transformation
## drops documents
corpus_kamala <- tm_map(corpus_kamala, removeWords, stopwords("english"))
## Warning in tm_map.SimpleCorpus(corpus_kamala, removeWords,
## stopwords("english")): transformation drops documents
corpus_kamala <- tm_map(corpus_kamala, stripWhitespace)
## Warning in tm_map.SimpleCorpus(corpus_kamala, stripWhitespace): transformation
## drops documents
# Create DTM and generate word cloud
dtm_kamala <- TermDocumentMatrix(corpus_kamala)
matrix_kamala <- as.matrix(dtm_kamala)
word_freqs_kamala <- sort(rowSums(matrix_kamala), decreasing = TRUE)
word_freqs_kamala_df <- data.frame(word = names(word_freqs_kamala), freq = word_freqs_kamala)

set.seed(1234)
wordcloud(words = word_freqs_kamala_df$word, freq = word_freqs_kamala_df$freq, min.freq = 2, max.words = 500, random.order = FALSE, rot.per = 0.35, colors = palette)
## Warning in wordcloud(words = word_freqs_kamala_df$word, freq =
## word_freqs_kamala_df$freq, : noopener could not be fit on page. It will not be
## plotted.
## Warning in wordcloud(words = word_freqs_kamala_df$word, freq =
## word_freqs_kamala_df$freq, : noreferrer could not be fit on page. It will not
## be plotted.
## Warning in wordcloud(words = word_freqs_kamala_df$word, freq =
## word_freqs_kamala_df$freq, : relnofollow could not be fit on page. It will not
## be plotted.
title(main = "Topics Related to Kamala Harris", col.main = "blue", font.main = 4, cex.main = 1.5)