combine_terms: combine_terms

Description Usage Arguments Details Value Examples

View source: R/dictionary.R

Description

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

Usage

1
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.

Details

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

Value

An aggregated DocumentTermMatrix object.

Examples

1
2
3
4
5
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)

R.temis documentation built on May 13, 2021, 1:08 a.m.