get_topics: Perform topic modeling on a corpus

Description Usage Arguments Examples

View source: R/get_topics.R

Description

Perform topic modeling on a corpus

Usage

1
get_topics(corp, dfm_subset, num_topics, num_ngrams, ...)

Arguments

corp

A corpus object

dfm_subset

A logical expression indicating elements to keep: missing values are taken as false

num_topics

The number of topics to return

num_ngrams

The phrase length to

...

Additional options passed to Text.Replace::create_dfm()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 

 # load AFMC We Need data set
   csv = "path/to/AFMC_We_Need/data/file.csv"
 
 # Extract text from the CSV file  
   DATA = Text.Replace:::extract_text(csv)
 
 # Subset DATA for question 1 of the Field Survey as object \code{q1f_DATA}
   q1f_DATA = subset(DATA, Source == 'Field Survey' & Question == 1)

 # Create the corpus object
   corp = Text.Replace::create_corpus(q1f_DATA, "Comments")
   
 # Get the topics 
   Text.Replace::get_topics(corp = corp,
                            dfm_subset = Base == "Robins",
                            num_topics = 10,
                            num_ngrams = 1,
                            remove = quanteda::stopwords("english")) 


## End(Not run)

clawilso15/Text.Replace documentation built on Feb. 6, 2021, 5:45 a.m.