Data Scientist David Robinson caused a bit of a stir in the media when he analyzed Donald Trump's tweets and revealed that those sent from an Android device were likely sent by the candidate himself, while those sent from an iPhone were likely sent by campaign staffers. The difference? As seen in the chart below, Android-based tweets used angrier, negative words while iPhone-based tweets tended be straightforward campaign announcements and hashtag promotions. The news was reported in Scientific American, the LA Times, PC Magazine and David even gave an interview with Time magazine.

David used the R language and several contributed packages to analyze Trump's tweets. (The R code behind the analysis is available on Github as an R Markdown document, which also makes an excellent example of literate programming with R.) He used the twitteR package and the userTimeline function to download tweets and metadata from the @realDonaldTrump account, which formed the raw data for the analysis. The tidytext package function unnest_tokens extracted and standardized individual words from the tweets, from which simple tabulation generated the chart above of words more frequently used by iPhone and Android tweets. The tidytext package was also used to measure the sentiment of the words used, and again there was a clear difference between iPhone and Android tweets in use of words related to sadness, fear, anger and disgust; and surprise, anticipation, trust and joy.

For more details on David's analysis of the Trump tweets, and a fascinating hypothesis that an iPhone-based staffer is attempting to emulate the style of the real Trump's tweets, check out his blog post linked below.

Variance Explained: Text analysis of Trump's tweets confirms he writes only the (angrier) Android half