Learn R Programming

bertopicr (version 0.3.6)

get_topics_df: Get Topics DataFrame Function

Description

This function retrieves all topics from a BERTopic model and converts them into a data frame or tibble format.

Usage

get_topics_df(model, return_tibble = TRUE)

Value

A data.frame or tibble with columns for the word, score, and topic number across all topics.

Arguments

model

A BERTopic model object. Must be passed from the calling environment.

return_tibble

Logical. If TRUE, returns a tibble. If FALSE, returns a data.frame. Default is TRUE.

Examples

Run this code
# \donttest{
if (exists("topic_model")) {
  topics_df <- get_topics_df(model = topic_model)
  print(topics_df)
} else {
  message("No topic_model found. Please train or load a model first.")
}
# }

Run the code above in your browser using DataLab