top_terms: Get Top Terms for a Topic

View source: R/top_terms.R

top_termsR Documentation

Get Top Terms for a Topic

Description

Returns top-N terms for a topic ranked by probability.

Usage

top_terms(mod, topic_id, n_terms)

Arguments

mod

an object with STM or LDA model.

topic_id

topic ID (numeric).

n_terms

the number of terms to return.

Value

A tibble with a ranked list of terms.

Examples

library(stm)

mod <- stm(poliblog5k.docs, 
           poliblog5k.voc, K=25,
           prevalence=~rating, 
           data=poliblog5k.meta,
           max.em.its=2, 
           init.type="Spectral") 

top_terms(mod, 1, 100)

paskn/topicl documentation built on Feb. 1, 2025, 9:33 p.m.