Learn R Programming

KDViz (version 1.3.1)

ReplaceByList: Replace a list of words by another

Description

Optimized replacement of words inside a text corpus.

Usage

ReplaceByList(corpus, wordsFile)

Arguments

corpus

a VCorpus or Corpus object.

wordsFile

a TXT file (two columns separated by tab). One column containing the final word to be in the corpus and a second, containing the word to replace. Example: clustering cluster_analysis clustering cluster

Value

An object inheriting from VCorpus and Corpus.

Details

This function is provided as a replacing words step in a corpus composition process, this list must have a .txt file extension made by two columns, one for words of replacement and other for words to be replaced.

See Also

See also BibToCorpus where this function is used internally.

Examples

Run this code
# NOT RUN {
data("KDVizData")
wordsToReplace <- system.file("extdata", "KDReplaceWords.txt", package = "KDViz")
myCorpus <- BibToCorpus(bibData = KDVizData, bibUnits = "Keywords",
  controlList = c("stripWhitespace", "removeNumbers"), stopWords = TRUE)

myNewCorpus <- ReplaceByList(myCorpus, wordsFile = wordsToReplace)
# }

Run the code above in your browser using DataLab