Learn R Programming

sentimentr (version 0.4.0)

sentiment_by: Polarity Score (Sentiment Analysis) By Groups

Description

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

Usage

sentiment_by(text.var, by = NULL, 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.
group.names
A vector of names that corresponds to group. Generally for internal use.
...
Other arguments passed to sentiment.

Value

Returns a data.table with grouping variables plus:
  • element_id - The id number of the original vector passed to sentiment
  • sentence_id - The id number of the sentences within each element_id
  • word_count - Word count summed by grouping variable
  • sd - Standard deviation (sd) of the sentiment/polarity score by grouping variable
  • ave_sentiment - Sentiment/polarity score mean average by grouping variable

See Also

Other sentiment.functions: sentiment