create_tweet_features: Create tweet features

create_tweet_featuresR Documentation

Create tweet features

Description

Given a data frame of tweets data, create_tweet_features() creates tweet features.

Usage

create_tweet_features(
  x,
  .req.columns.mapping = required.tweets.df.cols,
  .as.data.table = TRUE
)

Arguments

x

a data.frame data.table, or tibble recording tweets. For required column (naming and typing conventions) refer to ?required.tweets.df.cols. For an example see ?tweets.df.prototype.

.req.columns.mapping

a two-column data.frame mapping column names to (character vectors specifying) expected column classes. The first column must be named colname and have type character. The second column must be a list-column of character vectors and named accepted_types. (see ?required.tweets.df.cols).

...

Additional arguments passed to compute_tweet_features.

Value

A data.table. If, in addition, you pass the parameter-argument mapping .as.data.table = FALSE (e.g. create_tweet_features(df, .as.data.table = FALSE)), the return object is a tibble instead.

Complementary with the rtweet package

The column naming and typing conventions (see required.tweets.df.cols) conform with the data returned by rtweet functions lookup_statuses and lookup_tweets if called with parse = TRUE (the default behavior).

Note

Names and types/classes of x are expected to match the values mapped in required.tweets.df.cols (for an example, see tweets.df.prototype). An error will be raised if (a) any required column is missing (column name-based check), or (b) any the class of any required column does not match any of the accepted classes.


haukelicht/politicaltweets documentation built on July 3, 2023, 4:11 a.m.