mean_token_length: Calculate the average token length for each topic in a topic...

Description Usage Arguments Value References Examples

View source: R/mean_token_length.R

Description

Using the the N highest probability tokens for each topic, calculate the average token length for each topic

Usage

1
mean_token_length(topic_model, top_n_tokens = 10)

Arguments

topic_model

a fitted topic model object from one of the following: tm-class

top_n_tokens

an integer indicating the number of top words to consider, the default is 10

Value

A vector of average token lengths with length equal to the number of topics in the fitted model

References

Jordan Boyd-Graber, David Mimno, and David Newman, 2014. Care and Feeding of Topic Models: Problems, Diagnostics, and Improvements. CRC Handbooks ofModern Statistical Methods. CRC Press, Boca Raton, Florida.

Examples

1
2
3
4
5
# Using the example from the LDA function
library(topicmodels)
data("AssociatedPress", package = "topicmodels")
lda <- LDA(AssociatedPress[1:20,], control = list(alpha = 0.1), k = 2)
mean_token_length(lda)

topicdoc documentation built on Oct. 30, 2019, 11:26 a.m.