tcn_counts: Get conversation tweet counts

View source: R/tcn_counts.R

tcn_countsR Documentation

Get conversation tweet counts

Description

Return the tweet count per day, hour or minute for conversation ids.

Usage

tcn_counts(
  ids = NULL,
  token = NULL,
  endpoint = "recent",
  start_time = NULL,
  end_time = NULL,
  granularity = "day",
  retry_on_limit = TRUE,
  verbose = TRUE
)

Arguments

ids

List. Conversation ids.

token

List. Twitter API tokens.

endpoint

Character string. Twitter API v2 search endpoint. Can be either "recent" for the last 7 days or "all" if users app has access to historical "full-archive" tweets. Default is "recent".

start_time

Character string. Earliest tweet timestamp to return (UTC in ISO 8601 format). If NULL API will default to 30 days before end_time. Default is NULL.

end_time

Character string. Latest tweet timestamp to return (UTC in ISO 8601 format). If NULL API will default to now - 30 seconds. Default is NULL.

granularity

Character string. Granularity or period for tweet counts. Can be "day", "minute" or "hour". Default is "day".

retry_on_limit

Logical. When the API v2 rate-limit has been reached wait for reset time. Default is TRUE.

verbose

Logical. Output additional information. Default is TRUE.

Value

A dataframe of conversation ids and counts.

Note

A rate-limit of 300 requests per 15 minute window applies. If a conversation count request contains more than 31 days-worth of results it will use more than one request as API results will be paginated.

Examples

## Not run: 
# get tweet count for conversation thread over approximately 7 days
counts <-
  tcn_counts(
    ids = c("xxxxxx", "xxxxxx"),
    token = token,
    endpoint = "all",
    start_time = "2020-09-30T01:00:00Z",
    end_time = "2020-10-07T01:00:00Z",
    granularity = "day"
  )

# total tweets per conversation id for period
counts$counts |> dplyr::count(conversation_id, wt = tweet_count)

## End(Not run)


voson.tcn documentation built on Aug. 30, 2022, 5:07 p.m.