Created
November 11, 2015 12:06
-
-
Save trengrj/0ca89e8ef8396e454dbb to your computer and use it in GitHub Desktop.
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(tm) | |
docs = Corpus(VectorSource(places$title)) | |
docs <- tm_map(docs, removePunctuation) | |
docs <- tm_map(docs, tolower) | |
docs <- tm_map(docs, removeWords, c("bad","words")) | |
docs <- tm_map(docs, removeWords, stopwords("english")) | |
docs <- tm_map(docs, stripWhitespace) | |
docs <- tm_map(docs, PlainTextDocument) | |
dtm <- DocumentTermMatrix(docs) | |
freq <- sort(colSums(as.matrix(dtm)), decreasing=TRUE) | |
head(freq, 14) | |
wf <- data.frame(word=names(freq), freq=freq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment