Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

run_topic_model

Calculate a topic model


Description

Calculate a topic model using Latent Dirichlet Allocation (LDA) or Correlated Topic Models (CTM), using the topicmodels package.

Usage

run_topic_model(dtm, type = "lda", n_topics = 5, iterations = 2000)

Arguments

dtm

a Document Term Matrix (DTM)

type

string specififying the type of model to run. Either 'lda' (the default) or 'ctm'.

n_topics

Number of topics to calculate

iterations

The number of iterations. Only relevant for LDA.

Value

A topic model with the specified parameters.

Note

This is a basic wrapper function designed to allow consistent specification of model parameters within shiny apps.

See Also

make_dtm for constructing data to pass to this function; screen_topics for interactive visualisation of topic model results.

Examples

# import data
file_location <- system.file(
  "extdata",
  "avian_ecology_bibliography.ris",
  package = "revtools"
)
x <- read_bibliography(file_location)

# run a topic model based on these data
# note: the following lines can take a very long time to run, especially for large datasets!
x_dtm <- make_dtm(x$title)
## Not run: x_lda <- run_topic_model(x_dtm, "lda", 5, 5000)

revtools

Tools to Support Evidence Synthesis

v0.4.1
GPL-3
Authors
Martin J. Westgate [aut, cre]
Initial release
2019-12-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.