Learn R Programming

sentopics (version 0.7.4)

melt.sentopicmodel: Melt for sentopicmodels

Description

This function extracts the estimated document mixtures from a topic model and returns them in a long data.table::data.table format.

Usage

# S3 method for sentopicmodel
melt(data, ..., include_docvars = FALSE)

Value

A data.table::data.table in the long format, where each line is the estimated proportion of a single topic/sentiment for a document. For JST and rJST models, the probability is also decomposed into 'L1' and 'L2' layers, representing the probability at each layer of the topic-sentiment hierarchy.

Arguments

data

a model created from the LDA(), JST() or rJST() function and estimated with fit()

...

not used

include_docvars

if TRUE, the melted result will also include the docvars stored in the tokens object provided at model initialization

Author

Olivier Delmarcelle

See Also

topWords() for extracting representative words, data.table::melt() and data.table::dcast()

Examples

Run this code
# only returns topic proportion for LDA models
lda <- LDA(ECB_press_conferences_tokens)
lda <- fit(lda, 10)
melt(lda)

# includes sentiment for JST and rJST models
jst <- JST(ECB_press_conferences_tokens)
jst <- fit(jst, 10)
melt(jst)

Run the code above in your browser using DataLab