sentopics_labels: Setting topic or sentiment labels

View source: R/timeSeries.R

sentopics_labelsR Documentation

Setting topic or sentiment labels

Description

Extract or replace the labels of a sentopicmodel. The replaced labels will appear in most functions dealing with the output of the sentomicmodel.

Usage

sentopics_labels(x, flat = TRUE)

sentopics_labels(x) <- value

Arguments

x

a sentopicmodel created from the LDA(), JST(), rJST() or sentopicmodel() function

flat

if FALSE, return a list of dimension labels instead of a character vector.

value

a list of future labels for the topic model. The list should be named and contain a character vector for each dimension to label. See the examples for a correct usage.

Value

a character vector of topic/sentiment labels.

Author(s)

Olivier Delmarcelle

See Also

mergeTopics

Other sentopics helpers: sentopics_date(), sentopics_sentiment()

Examples

# by default, sentopics_labels() generate standard topic names
lda <- LDA(ECB_press_conferences_tokens)
sentopics_labels(lda)

# to change labels, a named list must be provided
sentopics_labels(lda) <- list(
 topic = paste0("superTopic", 1:lda$K)
)
sentopics_labels(lda)

# using NULL remove labels
sentopics_labels(lda) <- NULL
sentopics_labels(lda)

# also works for JST/rJST models
jst <- JST(ECB_press_conferences_tokens)
sentopics_labels(jst) <- list(
  topic = paste0("superTopic", 1:jst$K),
  sentiment = c("negative", "neutral", "positive")
)
sentopics_labels(jst)

# setting flat = FALSE return a list or labels for each dimension
sentopics_labels(jst, flat = FALSE)

sentopics documentation built on May 31, 2023, 8:26 p.m.