R.temis (version 0.1.3)

combine_terms: combine_terms

Description

Aggregate terms in a document-term matrix to according to groupings specified by a dictionary.

Usage

combine_terms(dtm, dict)

Arguments

dtm

A DocumentTermMatrix object.

dict

A data.frame with one row per term in dtm that should be retained. The row names must match names of rows in dtm, and the first column must give the term into which it should be transformed.

Value

An aggregated DocumentTermMatrix object.

Details

If several terms use the same transformation, they will be aggregated together. Terms missing from dict will be dropped.

Examples

Run this code
# NOT RUN {
file <- system.file("texts", "reut21578-factiva.xml", package="tm.plugin.factiva")
corpus <- import_corpus(file, "factiva", language="en")
dtm <- build_dtm(corpus)
dict <- dictionary(dtm)
combine_terms(dtm, dict)

# }

Run the code above in your browser using DataCamp Workspace