Learn R Programming

rJST (version 1.3)

topNwords: Show top N words for topics/sentiments

Description

This method returns a vector containing the N 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 N words of every topic will be returned.

Usage

topNwords(x, N, topic = NULL, sentiment = NULL)

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

# S4 method for JST_reversed.result,numeric,ANY,ANY topNwords(x, N)

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

# S4 method for JST.result,numeric,ANY,ANY topNwords(x, N)

Arguments

x

A results object from any of the models in the package

N

Integer. The number of words to return.

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 N words for the requested topic-sentiment combination. Otherwise a data.frame containing the top N words for every topic-sentiment combination.

Examples

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

Run the code above in your browser using DataLab