R: Downweighted Zeros Averaging

average_downweighted_zero {sentimentr} | R Documentation

## Downweighted Zeros Averaging

### 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

    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

    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))

[Package sentimentr version 2.4.2 Index]