In addition to question R Text mining - how to change texts in R data frame column into several columns with word frequencies? I am wondering how I can manage to make column
The dev version of qdap
(should go to CRAN within the next few days) does ngrams. For now you'll need to use the dev version. On the toy data set this is fast but on a larger data set such as qdap
's mraja1
data set requires ~5 minutes to complete. You could:
Here's the code to get the dev version of qdap
and run the bigram search:
library(devtools)
install_github("qdap", "trinker")
library(qdap)
## this gets the bigrams
bigrams <- sapply(ngrams(DATA$state)[[c("all_n", "n_2")]], paste, collapse=" ")
## This searches by grouping variable for bigram use
termco(DATA$state, DATA$person, bigrams)
## To get raw values
termco(DATA$state, DATA$person, bigrams)[["raw"]]