select_documents: Select Documents rom a TermDocumentMatrix/DocumentTermMatrix

Description Usage Arguments Value Examples

Description

Select documents from a TermDocumentMatrix or DocumentTermMatrix matching a regular expression.

Usage

1

Arguments

x

A TermDocumentMatrix or DocumentTermMatrix.

pattern

A regex pattern used to select documents.

invert

logical. If TRUE the pattern is inverted to exclude these documents.

...

Other arguments passed to grepl (perl = TRUE is hard coded).

Value

Returns a TermDocumentMatrix or DocumentTermMatrix.

Examples

1
2
3
4
5
6
(x <-with(presidential_debates_2012, q_dtm(dialogue, paste(time, person, sep = "_"))))
select_documents(x, 'romney', ignore.case=TRUE)
select_documents(x, '^(?!.*romney).*$', ignore.case = TRUE)      # regex way to invert
select_documents(x, 'romney', ignore.case = TRUE, invert = TRUE) # easier way to invert
(y <- with(presidential_debates_2012, q_tdm(dialogue, paste(time, person, sep = "_"))))
select_documents(y, '[2-3]')

gofastr documentation built on May 2, 2019, 5:39 a.m.