6 Twitter Streams

This overview shows an example script to collect tweets based on keywords on a daily basis via crontab. The script saves the stream for the specified keywords and in regular steps saves a data frame so that the file won’t be too big to handle.

6.3 Connect with Twitter App

The next lines of code build a connection with your twitter app. If you haven’t set up this file already please do so as it is explained in the rtweets Package documentation. Otherwise this script will not work.

6.4 Data Collection

6.4.1 Step 1)

Define the keyword(s) you want to follow.

6.4.2 Step 2)

Set up the time frame of the stream, i.e., after when a data frame will be saved to keep data files small. This version defines a stream which collects data for 4 hours straight before starting a new data frame. Repeating the script for 8 times a day thus gives a full day of Tweets.