extract_topics: Apply topic modeling to a corpus

View source: R/text_preprocessing.R

extract_topicsR Documentation

Apply topic modeling to a corpus

Description

This function implements a simple non-negative matrix factorization (NMF) approach to topic modeling, without requiring additional packages.

Usage

extract_topics(
  text_data,
  text_column = "abstract",
  n_topics = 5,
  max_terms = 10,
  n_iterations = 50,
  seed = NULL
)

Arguments

text_data

A data frame containing the text data

text_column

Name of the column containing the text

n_topics

Number of topics to extract

max_terms

Maximum number of terms per topic to return

n_iterations

Number of iterations for the NMF algorithm

seed

Optional seed for reproducibility. If NULL, no seed is set.

Value

A list containing topic-term and document-topic matrices


LBDiscover documentation built on June 16, 2025, 5:09 p.m.