Learn R Programming

bertopicr (version 0.3.6)

get_representative_docs_custom: Get Representative Documents for a Specific Topic

Description

This function filters a given data frame to select a specified number of representative documents from a particular topic. It uses random sampling to select the documents.

Usage

get_representative_docs_custom(df, topic_nr, n_docs)

Value

A vector of sampled documents corresponding to the specified topic.

Arguments

df

A data frame containing at least the columns 'Topic' and 'Document'.

topic_nr

An integer specifying the topic number to filter the documents.

n_docs

An integer specifying the number of documents to sample for the specified topic.

Examples

Run this code
# \donttest{
if (exists("df_docs")) {
  # df_docs must contain columns Topic, Document, and probs
  get_representative_docs_custom(df_docs, topic_nr = 3, n_docs = 5)
} else {
  message("No df_docs found. Create it before running this example.")
}
# }

Run the code above in your browser using DataLab