powered by
Interface to apply filter and index functions to corpora.
# S3 method for PCorpus tm_filter(x, FUN, ...) # S3 method for SimpleCorpus tm_filter(x, FUN, ...) # S3 method for VCorpus tm_filter(x, FUN, ...) # S3 method for PCorpus tm_index(x, FUN, ...) # S3 method for SimpleCorpus tm_index(x, FUN, ...) # S3 method for VCorpus tm_index(x, FUN, ...)
tm_filter returns a corpus containing documents where
tm_filter
FUN matches, whereas tm_index only returns the corresponding indices.
FUN
tm_index
A corpus.
a filter function taking a text document or a string (if x is a SimpleCorpus) as input and returning the logical value TRUE or FALSE.
x
SimpleCorpus
TRUE
FALSE
arguments to FUN.
data("crude") # Full-text search tm_filter(crude, FUN = function(x) any(grep("co[m]?pany", content(x))))
Run the code above in your browser using DataLab