sentiment_stanford_by: Polarity Score (Sentiment Analysis) By Groups

Description Usage Arguments Details Value

View source: R/sentiment_stanford_by.R

Description

Approximate the sentiment (polarity) of text by grouping variable(s).

Usage

1
2
sentiment_stanford_by(text.var, by = NULL,
  averaging.function = stansent::average_downweighted_zero, group.names, ...)

Arguments

text.var

The text variable.

by

The grouping variable(s). Default NULL uses the original row/element indices; if you used a column of 12 rows for text.var these 12 rows will be used as the grouping variable. Also takes a single grouping variable or a list of 1 or more grouping variables.

averaging.function

A function for performing the group by averaging. The default, average_downweighted_zero, downweights zero values in the averaging. Note that the function must handle NAs. The sentimentr functions average_weighted_mixed_sentiment and average_mean are also available. The former upweights negative when the analysts suspects the speaker is likely to surround negatives with positives (mixed) as a polite social convention but still the affective state is negative. The later is a standard mean average.

group.names

A vector of names that corresponds to group. Generally for internal use.

...

Other arguments passed to sentiment_stanford.

Details

Note that the coreNLP is expensive with regard to time. Typically it is better to use sentiment_stanford and do the merging and aggregation/summarization yourself.

Value

Returns a data.table with grouping variables plus:


trinker/stansent documentation built on Oct. 12, 2021, 11:19 a.m.