readDataframe: Read In a Text Document from a Data Frame

Description Usage Arguments Value See Also Examples

View source: R/reader.R

Description

Read in a text document from a row in a data frame.

Usage

1

Arguments

elem

a named list with the component content which must hold a data frame with rows as the documents to be read in. The names of the columns holding the text content and the document identifier must be "text" and "doc_id", respectively.

language

a string giving the language.

id

Not used.

Value

A PlainTextDocument representing elem$content.

See Also

Reader for basic information on the reader infrastructure employed by package tm.

Examples

1
2
3
4
5
6
7
8
docs <- data.frame(doc_id = c("doc_1", "doc_2"),
                   text = c("This is a text.", "This another one."),
                   stringsAsFactors = FALSE)
ds <- DataframeSource(docs)
elem <- getElem(stepNext(ds))
result <- readDataframe(elem, "en", NULL)
inspect(result)
meta(result)

Example output

Loading required package: NLP
<<PlainTextDocument>>
Metadata:  7
Content:  chars: 15

This is a text.
  author       : character(0)
  datetimestamp: 2019-01-04 04:56:09
  description  : character(0)
  heading      : character(0)
  id           : doc_1
  language     : en
  origin       : character(0)

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