| tm_filter {tm} | R Documentation |
Interface to apply filter and index functions to corpora.
## S3 method for class 'Corpus' tm_filter(x, ..., FUN, doclevel = TRUE, useMeta = FALSE) ## S3 method for class 'Corpus' tm_index(x, ..., FUN, doclevel = TRUE, useMeta = FALSE)
x |
A corpus. |
... |
Arguments to |
FUN |
A filter function returning a logical value. |
doclevel |
Logical. If the document level flag is set |
useMeta |
Logical. Should |
tm_filter returns a corpus containing documents where
FUN matches, whereas tm_index only returns the
corresponding indices.
sFilter for a filter using a simple statement query
language.
data("crude")
# Full-text search
tm_filter(crude, FUN = function(x) any(grep("co[m]?pany", x)))