Learn R Programming

qdap (version 1.3.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