filter.corpus: Return documents with matching conditions

Description Usage Arguments Examples

View source: R/filter.R

Description

Use filter() to select documents where conditions evaluated on document variables are true. Documents where the condition evaluates to NA are dropped. A tidy replacement for corpus_subset().

Usage

1
2
## S3 method for class 'corpus'
filter(.data, ..., .preserve = FALSE)

Arguments

.data

a quanteda object whose documents will be filtered

...

Logical predicates defined in terms of the document variables in .data, or a condition supplied externally whose length matches the number of ndoc(.data)'. See filter.

.preserve

Relevant when the .data input is grouped. If .preserve = FALSE (the default), the grouping structure is recalculated based on the resulting data, otherwise the grouping is kept as is.

Examples

1
2
3
data_corpus_inaugural %>%
    filter(Year < 1810) %>%
    summary()

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