by: Laurel Wind
Hypothesis: Donald Trump's use of Twitter has changed in relation to running as a Presidential candidate.
It should be noted there is extensive evidence to prove Trump himself only writes the tweets sent using an Android while his staff tweets using an iPhone. An example of this analysis can be found here. However, for this analysis, I chose to analyze Trump's tweets en masse, rather than simply looking at tweets sent using an Android or iPhone.
To test this hypothesis, I analyzed Trump's tweets from June 16, 2015 (the day he began his Presidential run) to the present.
Trump's twitter archive can be downloaded on Github.
This analysis utilizes R and requires the following packages: tm, wordcloud, stringr, syuzhet, ggplot2, lubridate, and ggthemes.
To begin this analysis, I looked into the specifications of Trump's tweets and performed a sentiment analysis and created a word cloud for the tweets.
wordcloud(wordCorpus2, scale=c(3, 0.1), max.words=200, random.order=FALSE, col="dodgerblue4")
wordcloud(wordCorpus, scale=c(3, 0.1), max.words=200, random.order=FALSE, col="dodgerblue4")
The word cloud on the left represents Trump's tweets in 2010 prior to his Presidential run. The word cloud on the right represents Trump's tweets since he announced his run for President. Based on the two word cloud, it is clear Trump's tweets were significantly affected by the presidential election, as his most used words include Trump and a handful of variations of his campaign slogan: "Make America Great Again".
After analyzing the word frequencies, I looked into the sentiment of his tweets by performing a sentiment analysis and created a graph charting his sentiment trends.
ggplot(sentimentTotals, aes(x=sentiment, y=count, fill=sentiment)) + geom_bar(stat="identity") + scale_fill_brewer(palette="Blues")
Based on the sentiment analysis, it is clear Trump's tweets were significantly affected by his presidential run as his tweets express more trust and anticipation than any other sentiment. This contrasts the general public's beliefs on Trump's tweets as they generally believe his tweets express more disgust and anger than other sentiments.
Following this analysis, I looked into the general content of his tweets to analyze any trends.
I analyzed the number of characters per tweet, the number of words per tweet, and the number of characters per word.
ggplot(tweetChars, aes(chars_per_tweet)) + geom_histogram(fill="dodgerblue4",aes(fill=..count..))
ggplot(tweetWords, aes(words_per_tweet)) + geom_histogram(fill="dodgerblue4",aes(fill=..count..))
ggplot(trumpDF, aes(x=words, y=chars)) + geom_point(shape = 21, colour = "blue", fill = "dodgerblue4", size = 1, stroke = 1)
It is clear Trump's tweets tend toward the maximum number of characters, 140. This makes sense because during a presidential run, it is vital to make your points as clear as possible and often link to other media to elaborate on those thoughts.
Based on the charts, it is clear as the number of words increases, so does the character count, which makes sense. However, it is significant to note the spike in frequencies of tweets with 23-24 words. However there is no evidence to support why other than Trump's tweets since announcing his presidency have a mean of 115.5 characters with the average word in the English language containing 5 characters, resulting in the general trend of 23 words.
After analyzing the language of Trump's tweets, I looked into the timing of his tweets by performing an analysis on the trends of the day of week, month, and year of his tweets.
ggplot(trumpTweets, aes(x=created_at)) + geom_histogram(aes(fill=..count..)) + xlab("Created At")
ggplot(trumpTweets, aes(x=month(created_at, label=TRUE))) + geom_bar(aes(fill=..count..)) + xlab("Month")
Based on the graph, there is a significant increase in Trump tweets during the months of July and October. This directly correlates with his Presidential run as he most likely tweeted the most the month after he announced his Presidential run and the month directly before he became elected.
This graph provides many insights into Trump's Twitter trends, as the frequency of tweets spikes directly after he announces his run ,for President. His tweet frequency spikes again around August, the beginning of the Republican debates, and significantly decreases after debate season. However, the most significant change in Trump's frequency of tweets occurs directly before the Presidential Inauguration in January of 2017. This is a direct result of Trump's election as he no longer needs to campaign and soon transitions to using the official Presidential twitter handle.
After analyzing Trump's twitter archive since announcing his run for President, it is clear the trends in his tweets are a direct result of the events in his Presidential run.