Learn R Programming

revtools (version 0.2.2)

run_LDA: Calculate a topic model

Description

Run a topic model using either LDA or CTM from the topicmodels package.

Usage

run_LDA(x, topic_model, n_topics, iterations)

Arguments

x

a Document Term Matrix (DTM)

topic_model

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.

Examples

Run this code
# NOT RUN {
# 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)
# }
# NOT RUN {
x_LDA<-run_LDA(x_DTM, "lda", 5, 5000)
# }

Run the code above in your browser using DataLab