# NOT RUN {
# stream tweets mentioning "election" for 90 seconds
e <- stream_tweets("election", timeout = 90)
# data frame where each observation (row) is a different tweet
e
# users data also retrieved. can access it via users_data()
users_data(e)
# stream tweets mentioning Obama for 30 seconds
djt <- stream_tweets("realdonaldtrump", timeout = 30)
djt # prints tweets data preview
users_data(djt) # prints users data preview
# store large amount of tweets in files using continuous streams
# by default, stream_tweets() returns a random sample of all tweets
# leave the query field blank for the random sample of all tweets.
stream_tweets(timeout = (60 * 10), parse = FALSE, file_name = "tweets1")
stream_tweets(timeout = (60 * 10), parse = FALSE, file_name = "tweets2")
# parse tweets at a later time using parse_stream function
tw1 <- parse_stream("tweets1.json")
tw1
tw2 <- parse_stream("tweets2.json")
tw2
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab