O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Finding frequent terms

The tm package has a useful function called findFreqTerms, which is useful to find the frequency of the popular terms used. The second argument to the function restricts the results to terms that have a minimum frequency specified. We can also compute the occurrences by summing up the 1s and 0s for each term in the TDM. Then we can sort the list and display the highest and lowest frequency occurrences:

data.frame(findFreqTerms(dtms, 10000, Inf)) > findFreqTerms.dtms..10000..Inf. > 1 cake > 2 christmas > 3 design > 4 heart > 5 metal > 6 retrospot > 7 vintage freq <- colSums(as.matrix(dtms)) # there are xx terms length(freq) > [1] 62 ord <- order(freq) # look at the top and bottom number of terms freq[head(ord, 12)] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required