Shiny Contest Submission: Mapping the Geographic Distribution of Twitter Sentiments


This app provides a way to visualize the geographic distribution of Twitter conversations and their sentiments. To begin, enter one or more search terms in the Search Terms field. Each term should be in quotation marks. For example, searching for this - "Donald Trump" OR "Hillary Clinton" - will pull all tweets containing either of these terms. The search tool only retrieves tweets from users that have provided locations in their Twitter profiles. It geolocates these to a map of the United States.

This tool updates the map as it geolocates tweets. Modify the Tweets per Batch parameter to alter the rate at which tweets are collected. At the default batch setting of 500, the tool will geolocate tweets in groups of 500 until all tweets in the specified date range are collected. You can also modify the number of tweets that the app will collect from a search. By default, the app collects 500 tweets. To collect all available tweets containing a search term, simply leave this field empty before performing a search.

By default, this app displays Twitter data by location. The number of tweets found in a given location is represented by the size of the circle that marks that location. Click the Tweet View checkbox to see individual tweets for all locations.

You can also perform sentiment analysis on the data by clicking the Sentiment Analysis checkbox, which will appear when Tweet View is activated. The tool conducts sentiment analysis using the sentimentR package developed by Tyler Rinker. Once sentiment analysis complete, the corpus of tweets is automatically annotated to show which words have been assigned particularly large polarity scores. Finally, the user can download the data collected with this tool by clicking the Data Explorer tab and selecting Download Data.

One last thing to note, the Twitter Search API restricts users to 18,000 tweets every fifteen minutes. If you are "Rate Limited", the app will notify you and wait the necessary amount of time before resuming its search.


The geolocation tool behind this app was developed using publicly available geographic data collected from Wikipedia in conjunction with data gathered with Google's search API.

App -
RCloud Project -

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.