text <- c("A rose is a rose is a rose.",
"A Rose is red, a violet is blue!",
"A rose by any other name would smell as sweet.")
term_matrix(text)
# select certain terms
term_matrix(text, select = c("rose", "red", "violet", "sweet"))
# specify a grouping factor
term_matrix(text, group = c("Good", "Bad", "Good"))
# weight the texts
term_matrix(text, weights = c(1, 2, 10),
group = c("Good", "Bad", "Good"))
# include higher-order n-grams
term_matrix(text, ngrams = 1:3)
# select certain multi-type terms
term_matrix(text, select = c("a rose", "a violet", "sweet", "smell"))
Run the code above in your browser using DataLab