sentiment: Conduct dictionary-based sentiment analysis.

Description Usage Arguments Value See Also Examples

View source: R/sentiment.R

Description

Tokenizes character vectors, counts words, and then takes weighted average to estimate sentiment.

Usage

1
sentiment(x,tokens,scores)

Arguments

x

length n character vector. If you're input dictionary is lower case only, then be sure to preprocess inputs to x using tolower.

tokens

length m character vector containing dictionary words

scores

m x d numerical matrix containing scores for each dictionary word on d-dimensions. Values can be weighted continuous scores or binary.

Value

n x d numerical matrix with scores on x for dimensions d

See Also

count_tokens tokenize

Examples

1
2
3
4
5
6
dictionary <- c("great","good","bad","awful")
scores <- matrix(c(1,.5,-.5,-1),4,1)
sentiment("This package is great.",dictionary,scores)
sentiment("This package is good.",dictionary,scores)
sentiment("This package is bad.",dictionary,scores)
sentiment("This package is awful.",dictionary,scores)

markallenthornton/affectr documentation built on May 17, 2019, 2:15 a.m.