This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(caret) | |
| library(tm) | |
| # Training data. | |
| data <- c('Cats like to chase mice.', 'Dogs like to eat big bones.') | |
| corpus <- VCorpus(VectorSource(data)) | |
| # Create a document term matrix. | |
| tdm <- DocumentTermMatrix(corpus, list(removePunctuation = TRUE, stopwords = TRUE, stemming = TRUE, removeNumbers = TRUE)) |