Learn R Programming

voson.tcn (version 0.5.0)

tcn_counts: 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
)

Value

A dataframe of conversation ids and counts.

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.

Examples

Run this code
if (FALSE) {
# 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)
}

Run the code above in your browser using DataLab