removeSparseTerms: Remove Sparse Terms from a Term-Document Matrix

Description Usage Arguments Value Examples

View source: R/matrix.R

Description

Remove sparse terms from a document-term or term-document matrix.

Usage

1
removeSparseTerms(x, sparse)

Arguments

x

A DocumentTermMatrix or a TermDocumentMatrix.

sparse

A numeric for the maximal allowed sparsity in the range from bigger zero to smaller one.

Value

A term-document matrix where those terms from x are removed which have at least a sparse percentage of empty (i.e., terms occurring 0 times in a document) elements. I.e., the resulting matrix contains only terms with a sparse factor of less than sparse.

Examples

1
2
3

Example output

Loading required package: NLP
<<TermDocumentMatrix (terms: 5, documents: 20)>>
Non-/sparse entries: 94/6
Sparsity           : 6%
Maximal term length: 6
Weighting          : term frequency (tf)

tm documentation built on April 7, 2021, 3:01 a.m.