Learn R Programming

tm (version 0.7-12)

tm_reduce: Combine Transformations

Description

Fold multiple transformations (mappings) into a single one.

Usage

tm_reduce(x, tmFuns, ...)

Value

A single tm transformation function obtained by folding tmFuns

from right to left (via Reduce(..., right = TRUE)).

Arguments

x

A corpus.

tmFuns

A list of tm transformations.

...

Arguments to the individual transformations.

See Also

Reduce for R's internal folding/accumulation mechanism, and getTransformations to list available transformation (mapping) functions.

Examples

Run this code
data(crude)
crude[[1]]
skipWords <- function(x) removeWords(x, c("it", "the"))
funs <- list(stripWhitespace,
             skipWords,
             removePunctuation,
             content_transformer(tolower))
tm_map(crude, FUN = tm_reduce, tmFuns = funs)[[1]]

Run the code above in your browser using DataLab