Learn R Programming

bertopicr (version 0.3.6)

visualize_barchart: Visualize BERTopic Bar Chart

Description

This function visualizes the topics of a BERTopic model using Plotly and saves the output as an interactive HTML file. It checks for required Python modules and allows for custom file naming.

Usage

visualize_barchart(
  model,
  filename = "topics_topwords_interactive_barchart",
  open_file = FALSE
)

Value

Displays the interactive bar chart within the R environment and saves it as an HTML file.

Arguments

model

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

filename

A character string specifying the name of the HTML file to save the bar chart. Default is "topics_topwords_interactive_barchart". The .html extension is added automatically if not provided.

open_file

Logical. If TRUE, opens the HTML file after saving. Default is FALSE.

Examples

Run this code
# \donttest{
if (exists("topic_model")) {
  visualize_barchart(model = topic_model, filename = "custom_barchart",
                     open_file = TRUE)
} else {
  message("No topic_model found. Please train or load a model first.")
}
# }

Run the code above in your browser using DataLab