average_downweighted_zero: Downweighted Zeros Averaging

Description Usage Arguments Value Examples

Description

average_downweighted_zero- Downweight the zeros in a vector for averaging. This is useful in the context of language where we don't want the neutral sentences to have such a strong influence on the general sentiment of the discourse with multiple sentences. Essentially, this means neutral sentences are seen as having less emotional impact than a polarized sentence.

average_weighted_mixed_sentiment- Upweight the negative values in a vector while also downweighting the zeros in a vector. Useful for small text chunks with several sentences in which some one states a negative sentence but then uses the social convention of several positive sentences in an attempt to negate the impact of the negative. The affective state isn't a neutral but a slightly lessened negative state.

average_mean- Standard mean averaging with na.rm set to TRUE.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
average_downweighted_zero(x, na.rm = TRUE, ...)

average_weighted_mixed_sentiment(
  x,
  mixed.less.than.zero.weight = 4,
  na.rm = TRUE,
  ...
)

average_mean(x, na.rm = TRUE, ...)

Arguments

x

A numeric vector.

na.rm

logical. Should NA values should be stripped before the computation proceeds.

mixed.less.than.zero.weight

The weighting factor to multiply the negative elements of the vector by (this increases the intensity of the negatives in the numerator of the mean formula).

...

ignored.

Value

Returns a scalar summary of the re-weighted average

Examples

1
2
3
4
5
6
x <- c(1, 2, 0, 0, 0, -1)
mean(x)
average_downweighted_zero(x)
average_downweighted_zero(c(NA, x))
mean(c(0, 0, 0, x))
average_downweighted_zero(c(0, 0, 0, x))

Example output

[1] 0.3333333
[1] 0.4787655
[1] 0.4787655
[1] 0.2222222
[1] 0.4550668

sentimentr documentation built on Oct. 12, 2021, 9:06 a.m.