Learn R Programming

tm (version 0.3-3)

TermDocMatrix: Term-Document Matrix

Description

Constructs a term-document matrix.

Usage

TermDocMatrix(object, control = list())

Arguments

object
a text document collection
control
a named list of control options. The component weighting must be a weighting function capable of handling a dgCMatrix. It defaults to weightTf for term frequency weighting. All other options are delegated

Value

  • An S4 object of class TermDocMatrix containing a sparse term-document matrix. The following slots contain useful information:
  • DataThe sparse Matrix.
  • WeightingThe weighting mode applied to the term-document matrix.

See Also

The documentation to termFreq gives an extensive list of possible options.

Available weighting functions shipped with this package are weightTf, weightTfIdf, weightBin and weightLogical.

Examples

Run this code
data("crude")
(tdm <- TermDocMatrix(crude, control = list(weighting = weightTfIdf, stopwords = TRUE)))

Run the code above in your browser using DataLab