Learn R Programming

rJST (version 1.3)

top20words: Show top 20 words for topics/sentiments

Description

This method returns a vector containing the 20 words with the highest estimated parameter values for any of the models estimated in this package. If topic (and sentiment for the appropriate models) are not specified, the top 20 words of every topic will be returned.This method calls the generic topNwords method.

Usage

top20words(x, topic = NULL, sentiment = NULL)

# S4 method for JST_reversed.result,numeric,numeric top20words(x, topic = NULL, sentiment = NULL)

# S4 method for JST_reversed.result,ANY,ANY top20words(x)

# S4 method for JST.result,numeric,numeric top20words(x, topic = NULL, sentiment = NULL)

# S4 method for JST.result,ANY,ANY top20words(x)

Arguments

x

A results object from any of the models in the package

topic

(optional) Integer. The topic to return words from.

sentiment

(optional) Integer. The sentiment to return words from.

Value

If topic and sentiment are specified: A character vector containing the top 20 words for the requested topic-sentiment combination. Otherwise a data.frame containing the top 20 words for every topic-sentiment combination.

Examples

Run this code
# NOT RUN {
model <- jst(quanteda::dfm(quanteda::data_corpus_inaugural), paradigm())
top20words(model, topic = 1, sentiment = 1)
# }

Run the code above in your browser using DataLab