feature_sentiment: Sentiment features

Description Usage Arguments Details Value Examples

View source: R/feature_engineering.R

Description

Engineers features related to sentiment in Tweets.

Usage

1
2
feature_sentiment(data, doc_id_field, text_field, sentiments = c("nrc",
  "Bing-Liu", "MPQA"))

Arguments

data

a dataframe or tibble containing the text data and document id

doc_id_field

unquoted field name identifying the field within the data that represents the unique document id

text_field

unquoted field name identifying the field name in data that contains the text of the Tweet

sentiments

character, can be one or multiple of nrc, Bing-Liu or MPQA

Details

Tweets are first converted to lowercase before the features are calculated.

The sentiment features are calculated as a proportion of the total number of words in the Tweet:

Value

A data frame of document ids and their associated sentiment features

Examples

1
2
3
4
5
6
tweets <- data.frame(status_id = c(1234, 5678),
                     text = c("I love to tweet about one thing #onething #things",
                              "I have doubts about tweeting about another thing
                              #another thing #things"),
                     stringsAsFactors = FALSE)
feature_sentiment(tweets, status_id, text)

sebastian-fox/twitterfeatures documentation built on Nov. 5, 2019, 8:47 a.m.