library(dplyr) # displaying tbl_dfs
if (requireNamespace("tm", quietly = TRUE)) {
library(tm)
#' # tm package examples
txt <- system.file("texts", "txt", package = "tm")
ovid <- VCorpus(DirSource(txt, encoding = "UTF-8"),
readerControl = list(language = "lat"))
ovid
tidy(ovid)
# choose different options for collapsing text within each
# document
tidy(ovid, collapse = "")$text
tidy(ovid, collapse = NULL)$text
# another example from Reuters articles
reut21578 <- system.file("texts", "crude", package = "tm")
reuters <- VCorpus(DirSource(reut21578),
readerControl = list(reader = readReut21578XMLasPlain))
reuters
tidy(reuters)
}
Run the code above in your browser using DataLab