content_transformer: Content Transformers

Description Usage Arguments Value See Also Examples

View source: R/transform.R

Description

Create content transformers, i.e., functions which modify the content of an R object.

Usage

1

Arguments

FUN

a function.

Value

A function with two arguments:

x

an R object with implemented content getter (content) and setter (content<-) functions.

...

arguments passed over to FUN.

See Also

tm_map for an interface to apply transformations to corpora.

Examples

1
2
3
4
data("crude")
crude[[1]]
(f <- content_transformer(function(x, pattern) gsub(pattern, "", x)))
tm_map(crude, f, "[[:digit:]]+")[[1]]

Example output

Loading required package: NLP
<<PlainTextDocument>>
Metadata:  15
Content:  chars: 527
function (x, ...) 
{
    content(x) <- FUN(content(x), ...)
    x
}
<environment: 0x271fee0>
attr(,"class")
[1] "content_transformer" "function"           
<<PlainTextDocument>>
Metadata:  15
Content:  chars: 520

tm documentation built on April 7, 2021, 3:01 a.m.