Collect.listing.reddit: Collect reddit thread listings from subreddits

View source: R/Collect.listing.reddit.R

Collect.listing.redditR Documentation

Collect reddit thread listings from subreddits

Description

Collects thread listings for one or more specified subreddits and structures the data into a dataframe.

Usage

## S3 method for class 'listing.reddit'
Collect(
  credential,
  endpoint,
  subreddits,
  sort = "hot",
  period = "all",
  max = 25,
  waitTime = c(6, 8),
  ua = getOption("HTTPUserAgent"),
  writeToFile = FALSE,
  verbose = FALSE,
  ...
)

collect_reddit_listings(
  subreddits,
  sort = "new",
  period = NULL,
  max = 25,
  waitTime = c(6, 8),
  ua = vsml_ua(),
  writeToFile = FALSE,
  verbose = FALSE,
  ...
)

Arguments

credential

A credential object generated from Authenticate with class name "reddit".

endpoint

API endpoint.

subreddits

Character vector. Subreddit names to collect thread listings from.

sort

Character vector. Listing thread sort order. Options are "hot", "top", "new", and "rising". Default is "hot".

period

Character vector. Listing top threads by time period. Only applicable to sort order by "top". Options are "hour", "day", "week", "month", "year" and "all". Default is "all".

max

Numeric vector. Maximum number of threads in listing to return. Default is 25.

waitTime

Numeric vector. Time range in seconds to select random wait from in-between url collection requests. Minimum is 3 seconds. Default is c(6, 8) for a wait time chosen from between 6 and 8 seconds.

ua

Character string. Override User-Agent string to use in Reddit thread requests. Default is option("HTTPUserAgent") value as set by vosonSML.

writeToFile

Logical. Write collected data to file. Default is FALSE.

verbose

Logical. Output additional information about the data collection. Default is TRUE.

...

Additional parameters passed to function. Not used in this method.

Value

A tibble object with class names "listing" and "reddit".

Note

The reddit endpoint used for collection has maximum limit of 25 per listing.

Examples

## Not run: 
# subreddit url to collect threads from
subreddits  <- c("datascience")

redditListing <- redditAuth |>
  Collect(endpoint = "listing", subreddits = subreddits, sort = "new", writeToFile = TRUE)

## End(Not run)


vosonlab/vosonSML documentation built on April 28, 2024, 6:26 a.m.