A Sentiment Analysis of




from the Tweeter-In-Chief

For Trump, Twitter is his pen and his sword. Sometimes it is tipped with ink and at other times with blood, but regardless of which, he is always the loudest bird in the Twitterverse.

Donald Trump used Twitter as a personal soapbox during his campaign and has continued to do so through his presidency with no signs of slowing down, tweeting about his favorite topics including the media, Obamacare, and of course, "the haters and losers," for whom he has a veritable collection of nicknames. It has been a source of both bewilderment and entertainment, giving us an unfiltered look into Trump's id--exactly what is going through his mind at any given time.

It all started innocently enough. He joined the social networking site in March of 2009, when it was only three years old. His very first tweet was not posted by himself but by the publisher of Think Like a Champion Peter Costanzo, who was brainstorming ways to promote the book.

The handle '@DonaldTrump' had already been taken by another user, so Costanzo proposed the handle '@realDonaldTrump' instead. Trump liked the idea and agreed. Costanzo also uploaded the profile photo that still stands today, and he ran the account for eight more months until he left the publishing company. The account then sat mostly dormant for three more years. Starting in 2012, Trump started tweeting more frequently, at times about Obama, but mostly about pointless babble—his Diet Coke habit, his denial of global warming.


In all, his account is home to 36,900 tweets (not all written by him, and some deleted) and 47.5 million followers. He follows 45 users, mainly consisting of family members, White House staff, and Fox News hosts, but also Diamond and Silk, two sisters and former Democrats turned conservative YouTube vloggers who came into prominence for their support of Trump.

Detractors to Trump's use of Twitter include his wife Melania, who, when asked about the one habit she wished he'd give up, responded, "The tweeting." They include Chief of Staff John Kelly, part of whose job is to impose order on the documents and news articles that reach Trump's desk, which include inflammatory content created by members of the alt-right that he has read and retweeted.

Yet in spite of the critics from the left and from his own circle, Trump has continued to tweet. He has used it has a platform to speak to and connect with voters; when he tweets, people know they're hearing directly from him. He has used it as a weapon, intimidating rivals and throwing off critics. But most importantly, he has used it to capture the attention of voters bombarded by a dizzying array of information. With a couple taps, Trump generates the news. He drives the conversation. He is always in control of the storyline.


Sentiment analysis is the use of natural language processing techniques to quantify attitudes about a certain topic. Marketers often use sentiment analysis to understand how the public feels toward their brand. Twitter is the perfect data source for this type of analysis because the length of a tweet is capped at 140 characters, just enough for someone to convey a single idea or emotion about a particular subject, but also not too much.

The AFINN Lexicon

The technique I have used here uses a list of words (from -5 to 5) scored by Finn Årup Nielsen to measure positive and negative emotions present in language. Trump tweets in short, punchy sentences with a relatively small vocabulary, which is perfect, because the technique relies on words in the data source to match up with words in the scored words document. Trump's favorite words like great, sad, weak, fake are each assigned a value, then aggregated with the values of the other words in the tweet.

The Phone Switch

Data from Twitter conveniently includes a column about what kind of device the tweets come from, whether it's a desktop client, iPhone, Android, or another platform. Despite receiving a new secure, encrypted, Secret Service-approved device a day before his inauguration, Trump was notoriously attached to his personal Android phone, a Samsung Galaxy, the device from which he sent most of his own tweets and which his top aides feared was a security risk. "That Android has a microphone, which means that it can be turned into a room bug without anyone’s knowledge," explained security expert Bruce Schneieer. These are all of his tweets before he made the switch.

On March 8, tweets from the Android device mysteriously stopped, prompting people to wonder if he had finally given it up. Their speculations were confirmed when the White House Director of Social Media made the announcement on Twitter. But people had already figured out which tweets were composed by Trump himself and which were by his staff. According to David Robinson's analysis, "Android tweets are angrier and more negative, while the iPhone tweets tend to be benign announcements and pictures."

Both his staff and Trump's own tweets now come from an iPhone, making it difficult to tell who tweeted what. However, using data under the assumption that Android tweets were from Trump himself and iPhone tweets from his staff, a data scientist created DidTrumpTweetIt, training a machine learning model to classify whether his current tweets are his own or his staff's.

On Obama

Trump's back and forth with Obama began in March 2011, when Good Morning America interviewed him about running for president, and he claimed that he was skeptical of Obama's citizenship, later demanding to see Obama's birth certificate. Although that issue was put to rest, he frequently tweeted about his dissatisfication with the Obama administration, calling him the "worst president in the history of the United States."

On Clinton

Throughout his campaign and even during his presidency, Trump has taken to Twitter to attack Hillary Clinton, giving her the nickname "Crooked Hillary."

On the Media

Outside of his favorite show Fox & Friends, Trump has made it clear that he is no friend of the media, calling the New York Times and CNN the "failing" New York Times and the "Fake News Network." He has also called the media "dishonest," "corrupt," "disgusting," and above all, "an enemy of the people." In February of 2017, the Trump administration barred the Guardian, the New York Times, Politico, CNN, Buzzfeed, and BBC, among other media outlets from gaining entry to an off-camera press briefing. Although other presidents have had complicated relationhips with the press (Jefferson, Lincoln, Jackson)—the amount of repeated attacks and attempts to discredit it completely—are unprecedented.

Search for your own term

Use the search bar and hit enter to filter the graph for a topic like "Islam" or "immigration", or one of his favorite words like "great" or "weak."

Time of Day

The New York Times describes Trump waking up around 5:30 in the morning, "flip[ing] to CNN for news, mov['ing'] to “Fox &Friends” for comfort and messaging ideas, and sometimes watch['ing'] MSNBC’s “Morning Joe” because, friends suspect, it fires him up for the day." The imagery of Trump still in bed propped up by his pillow, tweeting manically, is rich.

Many of Trump's tweets are concentrated between 6:00-9:00 in the morning, and it's no coincidence that this overlaps with the time slot for the Fox & Friends.

When filtering for tweets from an Android device, most of these tweets were made early in the morning. This also confirms that the angrier tweets are from an Android device, and therefore written by Trump himself .

On the other hand, his staff's tweets typically came from later in the evening and were more positive.

A Timeline

Trump's sentiment also changes over time. During and following the 2016 election, his tweets were largely positive, celebrating his victory and signaling optimism for his presidency. Immediately after taking office, however, around late January and early February, Trump went on the defensive, defending his positions on illegal immigration and terrorism while attacking the media.

So what have we learned about Trump and his Twitter habit? Many of his tweets—especially ones that are congratulatory or thanking someone—are not his own, and made later in the day. He, on the other hand, prefers to tweet on his Android device in the morning, from the comfort of his own bed, fired up from his daily morning dose of cable news.

Although sentiment analysis is not completely accurate in capturing all of the nuances of Trump's language, it does a good job of parsing his emotional state at a given time and his attitude toward a certain person or subject. Moreover, as he continues to tweet, sentiment can be used in tandem with other features of natural language in machine learning determine whether a certain tweet was even his own.


Tweet data comes from the Trump Twitter Archive. The data was collected on January 25, 2017. I filtered out tweets that began with a quote or "RT" so that I would keep only tweets containing Trump's own language. The whole dataset was then filtered for his most retweeted tweets. Inspiration for the visualization go to Charlie Smart of The Pudding. I used Dremio to do the sentiment analysis. Learn more about how I built it here.