Learn R Programming

tm (version 0.5-9.1)

removeSparseTerms: Remove Sparse Terms from a Term-Document Matrix

Description

Remove sparse terms from a term-document matrix.

Usage

removeSparseTerms(x, sparse)

Arguments

x
A term-document matrix.
sparse
A numeric for the maximal allowed sparsity.

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

Run this code
data("crude")
tdm <- TermDocumentMatrix(crude)
removeSparseTerms(tdm, 0.2)

Run the code above in your browser using DataLab