Get Topic DataFrame Function
get_topic_df.RdThis function retrieves a specified number of words with high probability for a given topic number from a BERTopic model and returns the results in a data frame or tibble format.
Arguments
- model
A BERTopic model object. Must be passed from the calling environment.
- topic_number
The topic number for which words and scores are retrieved.
- top_n
Number of top words to retrieve for the specified topic. Default is 10. If greater than 10, it will be set to 10 as BERTopic returns a maximum of 10 words.
- return_tibble
Logical. If TRUE, returns a tibble. If FALSE, returns a data.frame. Default is TRUE.