Learn R Programming

bertopicr (version 0.3.6)

get_document_info_df: Get Document Information DataFrame

Description

This function retrieves document information from a BERTopic model and processes it to unnest list columns, replace NA values, and consolidate columns with the same prefix.

Usage

get_document_info_df(model, texts, drop_expanded_columns = TRUE)

Value

A data.frame or tibble with unnested and consolidated columns.

Arguments

model

A BERTopic model object.

texts

A character vector containing the preprocessed texts to be passed to the BERTopic model.

drop_expanded_columns

Logical. If TRUE, drops the expanded columns after consolidation. Default is TRUE.

Examples

Run this code
# \donttest{
if (exists("topic_model") && exists("texts_cleaned")) {
  document_info_df <- get_document_info_df(
    model = topic_model,
    texts = texts_cleaned,
    drop_expanded_columns = TRUE
  )
  print(document_info_df)
} else {
  message("No topic_model/texts_cleaned found. Please train or load a model first.")
}
# }

Run the code above in your browser using DataLab