Learn R Programming

quanteda (version 1.3.13)

textstat_select: Select rows of textstat objects by glob, regex or fixed patterns

Description

Users can subset output object of textstat_collocations, textstat_keyness or textstat_frequency based on "glob", "regex" or "fixed" patterns using this method.

Usage

textstat_select(x, pattern = NULL, selection = c("keep", "remove"),
  valuetype = c("glob", "regex", "fixed"), case_insensitive = TRUE)

Arguments

x

a textstat object

pattern

a character vector, list of character vectors, dictionary, collocations, or dfm. See pattern for details.

selection

whether to "keep" or "remove" the rows that match the pattern

valuetype

the type of pattern matching: "glob" for "glob"-style wildcard expressions; "regex" for regular expressions; or "fixed" for exact matching. See valuetype for details.

case_insensitive

ignore case when matching, if TRUE

Examples

Run this code
# NOT RUN {
period <- ifelse(docvars(data_corpus_inaugural, "Year") < 1945, "pre-war", "post-war")
mydfm <- dfm(data_corpus_inaugural, groups = period)
keyness <- textstat_keyness(mydfm)
textstat_select(keyness, 'america*')

# }

Run the code above in your browser using DataLab