make_td_thetas_df: get ranked topic importance for all documents

View source: R/make_td_thetas_df.R

make_td_thetas_dfR Documentation

get ranked topic importance for all documents

Description

get the top most important topics, in order, for each document

Usage

make_td_thetas_df(prepped_meta_obj, id_col, topicModel, 
                         topicModel_K, train_text, n_topics = 5)

Arguments

prepped_meta_obj

if using stm, this is the $meta dataframe in the object created by stm::prepDocuments

id_col

the column of prepped_meta_obj containing the unique ids for each row/document

topicModel

the stm topic model object to be operated on

topicModel_K

the number of topics K in topicModel

train_text

dataframe containing a column of documents to be used. This must be the dataframe/documents that were used to make topicModel

n_topics

the number of topics to be returned for each row/document

Value

a dataframe containing a row for each document that contains its most important topics

Examples

## Not run: 
data("tm_ex_dat")

make_td_thetas_df(prepped_meta_obj = tm_ex_dat$train_text_prepped$meta,
                  id_col = id_conversation,
                  topicModel = tm_ex_dat$topic_model_test,
                  topicModel_K = tm_ex_dat$topic_model_test$settings$call$K,
                  train_text = tm_ex_dat$train_text)

## End(Not run)

tknoch8/topicHelpers documentation built on Nov. 11, 2023, 1:15 a.m.