Learn R Programming

qdap (version 2.3.0)

exclude: Exclude Elements From a Vector

Description

exclude - Quickly exclude words from a word list

exclude.TermDocumentMatrix - TermDocumentMatrix method for exclude.

exclude.DocumentTermMatrix - DocumentTermMatrix method for exclude.

exclude.wfm - wfm method for exclude.

exclude.list - list method for exclude.

exclude.default - default method for exclude.

%ex% - Binary operator version of exclude .

Usage

exclude(word.list, ...)

# S3 method for TermDocumentMatrix exclude(word.list, ...)

# S3 method for DocumentTermMatrix exclude(word.list, ...)

# S3 method for wfm exclude(word.list, ...)

# S3 method for list exclude(word.list, ...)

# S3 method for default exclude(word.list, ...)

word.list %ex% ...

Arguments

word.list

A list/vector of words/terms, a wfm, DocumentTermMatrix, or TermDocumentMatrix to exclude from.

A vector (character/numeric) if element(s) to be excluded from the word.list.

Value

Returns a vector with the excluded terms removed.

Examples

Run this code
# NOT RUN {
exclude(1:10, 3, 4)
exclude(1:10, 3:4)
Top25Words
exclude(Top25Words, qcv(the, of, and))
exclude(Top25Words, "the", "of", "an")

#Using with term_match and termco 
terms <- term_match(DATA$state, qcv(th), FALSE) 
exclude(terms, "truth")  
#all together
termco(DATA$state, DATA$person, exclude(term_match(DATA$state, qcv(th), 
    FALSE), "truth"))

MTCH.LST <- exclude(term_match(DATA$state, qcv(th, i)), qcv(truth, stinks))
termco(DATA$state, DATA$person, MTCH.LST)

## Works with wfm
dat <- wfm(DATA$state, DATA$person)
the.no <- term_match(DATA$state, c("the", "no"))
exclude(dat, unlist(the.no))

## Works with tm's TermDocumentMatrix/DocumentTermMatrix
dat2 <- as.dtm(DATA$state, DATA$person)
out.dtm <- exclude(dat2, unlist(the.no))
tm::inspect(out.dtm)

dat3 <- as.tdm(DATA$state, DATA$person)
out.tdm <- exclude(dat3, unlist(the.no))
tm::inspect(out.tdm)
# }

Run the code above in your browser using DataLab