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

build_query

Build tweet query


Description

Build tweet query according to targeted parameters, can then be input to main get_all_tweets function as query parameter.

Usage

build_query(
  query,
  exclude = NULL,
  is_retweet = NULL,
  is_reply = FALSE,
  is_quote = FALSE,
  is_verified = FALSE,
  place = NULL,
  country = NULL,
  point_radius = NULL,
  bbox = NULL,
  geo_query = FALSE,
  remove_promoted = FALSE,
  has_hashtags = FALSE,
  has_cashtags = FALSE,
  has_links = FALSE,
  has_mentions = FALSE,
  has_media = FALSE,
  has_images = FALSE,
  has_videos = FALSE,
  has_geo = FALSE,
  lang = NULL
)

Arguments

query

string or character vector, search query or queries

exclude

string or character vector, tweets containing the keyword(s) will be excluded

is_retweet

If TRUE, only retweets will be returned; if FALSE, retweets will not be returned, only tweets will be returned; if NULL, both retweets and tweets will be returned.

is_reply

If TRUE, only reply tweets will be returned

is_quote

If TRUE, only quote tweets will be returned

is_verified

If TRUE, only tweets whose authors are verified by Twitter will be returned

place

string, name of place e.g. "London"

country

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

point_radius

numeric, a vector of two point coordinates latitude, longitude, and point radius distance (in miles)

bbox

numeric, a vector of four bounding box coordinates from west longitude to north latitude

geo_query

If TRUE user will be prompted to enter relevant information for bounding box or point radius geo buffers

remove_promoted

If TRUE, tweets created for promotion only on ads.twitter.com are removed

has_hashtags

If TRUE, only tweets containing hashtags will be returned

has_cashtags

If TRUE, only tweets containing cashtags will be returned

has_links

If TRUE, only tweets containing links and media will be returned

has_mentions

If TRUE, only tweets containing mentions will be returned

has_media

If TRUE, only tweets containing a recognized media object, such as a photo, GIF, or video, as determined by Twitter will be returned

has_images

If TRUE, only tweets containing a recognized URL to an image will be returned

has_videos

If TRUE, only tweets containing contain native Twitter videos, uploaded directly to Twitter will be returned

has_geo

If TRUE, only tweets containing Tweet-specific geolocation data provided by the Twitter user will be returned

lang

string, a single BCP 47 language identifier e.g. "fr"

Value

a query string

Examples

## Not run: 
query <- build_query("happy", is_retweet = FALSE, 
                     point_radius = TRUE, place = "new york", 
                     country = "US")

## 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.