| predict.SentimentDictionaryWeighted | R Documentation | 
Function takes a dictionary of class SentimentDictionaryWeighted with weights 
as input. It then applies this dictionary to textual contents in order to calculate
a sentiment score.
## S3 method for class 'SentimentDictionaryWeighted'
predict(
  object,
  newdata = NULL,
  language = "english",
  weighting = function(x) tm::weightTfIdf(x, normalize = FALSE),
  ...
)
object | 
 Dictionary of class   | 
newdata | 
 A vector of characters, a   | 
language | 
 Language used for preprocessing operations (default: English).  | 
weighting | 
 Function used for weighting of words; default is a a link to the tf-idf scheme.  | 
... | 
 Additional parameters passed to function for e.g. preprocessing.  | 
data.frame with predicted sentiment scores.
SentimentDictionaryWeighted, generateDictionary and
compareToResponse for default dictionary generations
#' # Create a vector of strings
documents <- c("This is a good thing!",
               "This is a very good thing!",
               "This is okay.",
               "This is a bad thing.",
               "This is a very bad thing.")
response <- c(1, 0.5, 0, -0.5, -1)
# Generate dictionary with LASSO regularization
dictionary <- generateDictionary(documents, response)
# Compute in-sample performance
sentiment <- predict(dictionary, documents)
compareToResponse(sentiment, response)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.