get_tweets {Twitmo} | R Documentation |
Sample tweets by streaming or searching
Description
Collect Tweets via streaming or searching.
Usage
get_tweets(
method = "stream",
location = c(-180, -90, 180, 90),
timeout = Inf,
keywords = "",
n_max = 100L,
file_name = NULL,
...
)
Arguments
method |
Character string. Supported methods are streaming and searching.
The default method is streaming |
location |
Character string of location to sample from. Can be a three letter country code i.e. "USA" or a city name like "berlin".
Use |
timeout |
Integer. Limit streaming time in seconds. By default will stream indefinitely until user interrupts by pressing [ctrl + c]. |
keywords |
Character string of keywords provided via a comma separated character string. Only for searching Tweets.If you want to stream Tweets for a certain location AND filter by keywords use the location parameter and after sampling use the filter_tweets function. If you are using the search method instead of streaming keywords WILL work together with a location but will yield only a very limited number of Tweets. |
n_max |
Integer value. Only applies to the |
file_name |
Character string of desired file path and file name where Tweets will be saved. If not specified, will write to stream_tweets.json in the current working directory. |
... |
Additional arguments passed to stream_tweets or search_tweets. |
Details
A function that calls on stream_tweets and search_tweets (depending on the specified method) and is specifically tailored for sampling geo-tagged data. This function provides supports additional arguments like location for convenient sampling of geo-tagged Tweets. Tweets can be searched up to 9 days into the past.
Value
Either a json file in the specified directory.
References
https://developer.twitter.com/en/docs/twitter-api/v1/tweets/search/api-reference/get-search-tweets https://developer.twitter.com/en/docs/twitter-api/v1/tweets/sample-realtime/api-reference/get-statuses-sample
See Also
Examples
## Not run:
# live stream tweets from Germany for 60 seconds and save to current working directory
get_tweets(method = "stream",
location = "DEU",
timeout = 60,
file_name = "german_tweets.json")
# OR
# live stream tweets from berlin for an hour
get_tweets(method = "stream",
location = "berlin",
timeout = 3600,
file_name = "berlin_tweets.json")
# OR
# use your own bounding box coordinates to strean tweets indefinitely (interrupt to stop)
get_tweets(method = 'stream',
location = c(-125, 26, -65, 49),
timeout = Inf)
## End(Not run)