filter.corpus: Return documents with matching conditions

View source: R/filter.R

filter.corpusR Documentation

Return documents with matching conditions

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

## 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

data_corpus_inaugural %>%
    filter(Year < 1810) %>%
    summary()


quanteda/quanteda.tidy documentation built on April 5, 2025, 2:50 p.m.