Learn R Programming

qdap (version 0.2.5)

bag.o.words: Bag of Words

Description

bag.o.words - Reduces a text column to a bag of words. breaker - Reduces a text column to a bag of words and qdap recognized end marks. word.split - Reduces a text column to a list of vectors of bag of words and qdap recognized end marks (i.e., ".", "!", "?", "*", "-").

Usage

bag.o.words(text.var, apostrophe.remove = FALSE, ...)

  breaker(text.var)

  word.split(text.var)

Arguments

text.var
The text variable.
apostrophe.remove
logical. If TRUE removes apostrophe's from the output.
...
further arguments passed to strip function.

Value

  • Returns a vector of striped words. breaker - returns a vector of striped words and qdap recognized endmarks (i.e., ".", "!", "?", "*", "-").

Examples

Run this code
bag.o.words("I'm going home!")
bag.o.words("I'm going home!", apostrophe.remove = TRUE)

bag.o.words(DATA$state)
by(DATA$state, DATA$person, bag.o.words)
lapply(DATA$state,  bag.o.words)

breaker(DATA$state)
by(DATA$state, DATA$person, breaker)
lapply(DATA$state,  breaker)

word.split(c(NA, DATA$state))

Run the code above in your browser using DataLab