filter.textstat: Return rows with matching conditions including feature...

Description Usage Arguments See Also Examples

View source: R/filter.R

Description

Use filters to find rows of the return objects from many textstat_*() functions where conditions are true, including matches to features using "glob", "regex" or "fixed" patterns.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'textstat'
filter(
  .data,
  ...,
  pattern = NULL,
  valuetype = c("glob", "regex", "fixed"),
  case_insensitive = TRUE
)

Arguments

.data

a textstat object returned from one of the applicable textstat_* functions in quanteda

...

filter conditions passed to dplyr dplyr::filter()

pattern

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

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

See Also

quanteda.textstats::textstat_collocations(), quanteda.textstats::textstat_keyness(), quanteda.textstats::textstat_frequency()

Examples

1
2
3
4
5
6
7
8
9
period <- ifelse(docvars(data_corpus_inaugural, "Year") < 1945,
                 "pre-war", "post-war")
mydfm <- tokens(data_corpus_inaugural) %>%
    dfm() %>%
    dfm_group(groups = period)
keyness <- quanteda.textstats::textstat_keyness(mydfm)
filter(keyness, pattern = "america*")
filter(keyness, p < .00001, pattern = "america*")
filter(keyness, p < .00001) %>% head()

quanteda/quanteda.tidy documentation built on April 11, 2021, 3:44 p.m.