TermDocumentMatrix {tm}R Documentation

Term-Document Matrix

Description

Constructs a term-document matrix or a document-term matrix.

Usage

TermDocumentMatrix(object, control = list())
DocumentTermMatrix(object, control = list())

Arguments

object a corpus
control a named list of control options. The component weighting must be a weighting function capable of handling a TermDocumentMatrix. It defaults to weightTf for term frequency weighting. All other options are delegated internally to a termFreq call.

Value

An object of class TermDocumentMatrix or class DocumentTermMatrix containing a sparse term-document matrix or document-term matrix. The following slots contain useful information:

Weighting The weighting applied to the matrix.

Author(s)

Ingo Feinerer

See Also

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

Available weighting functions shipped with the tm package are weightTf, weightTfIdf, and weightBin.

Examples

data("crude")
tdm <- TermDocumentMatrix(crude, control = list(weighting = weightTfIdf, stopwords = TRUE))
dtm <- DocumentTermMatrix(crude, control = list(weighting = weightTfIdf, stopwords = TRUE))
inspect(tdm[165:170,1:5])
inspect(dtm[1:5,165:170])

[Package tm version 0.3-4.1 Index]