tmMap-methods {tm}R Documentation

Methods for Function tmMap in Package ‘tm’

Description

Methods for function tmMap in package tm.

Methods

object = "Corpus", FUN, ..., lazy = FALSE
Applies FUN onto each element of object. Note that document specific metadata (i.e., DMetaData(object) is automatically passed to FUN as argument DMetaData. FUN must be a function which returns a TextDocument. If lazy is set, so-called lazy mapping is activated, i.e., mappings are delayed until the documents' content is accessed. Lazy mapping is useful when working with large corpora but only a few documents are accessed, as it avoids applying the mapping to all elements in the document collection.

Note

Please be aware that lazy transformations are an experimental feature and change R's standard evaluation semantics.

See Also

See getTransformations for available transformations shipped with tm. See materialize for manually materializing lazy transformations.

Examples

data("crude")
tmMap(crude, stemDoc)

headings <- function(object, ...) {
new("PlainTextDocument", Heading(object), Cached = TRUE, DateTimeStamp =
Sys.time(), ID = ID(object), Language = Language(object))
}
inspect(tmMap(crude, headings))

[Package tm version 0.3-3 Index]