Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_country_tweets

Get tweets with country parameter


Description

This function collects tweets containing strings or hashtags between specified date ranges filtering by country. Tweet-level data is stored in a data/ path as a series of JSONs beginning "data_"; User-level data is stored as a series of JSONs beginning "users_". If a filename is supplied, this function will save the result as a RDS file, otherwise it will return the results as a data.frame.

Usage

get_country_tweets(
  query,
  country,
  start_tweets,
  end_tweets,
  bearer_token,
  file = NULL,
  data_path = NULL,
  bind_tweets = TRUE,
  verbose = TRUE,
  ...
)

Arguments

query

string or character vector, search query or queries

country,

string, name of country as ISO alpha-2 code e.g. "GB"

start_tweets

string, starting date

end_tweets

string, ending date

bearer_token

string, bearer token

file

string, name of the resulting RDS file

data_path

string, if supplied, fetched data can be saved to the designated path as jsons

bind_tweets

If TRUE, tweets captured are bound into a data.frame for assignment

verbose

If FALSE, query progress messages are suppressed

...

arguments will be passed to build_query() function. See ?build_query() for further information.

Value

a data.frame

Examples

## Not run: 
bearer_token <- "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
get_country_tweets("happy", country = "GB", 
                   "2021-01-01T00:00:00Z", "2021-01-01T00:10:00Z", 
                   bearer_token, data_path = "data/")

## End(Not run)

academictwitteR

Access the Twitter Academic Research Product Track V2 API Endpoint

v0.1.0
MIT + file LICENSE
Authors
Christopher Barrie [aut, cre] (<https://orcid.org/0000-0002-9156-990X>), Justin Chun-ting Ho [aut] (<https://orcid.org/0000-0002-7884-1059>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.