Code Used:
cards <- Corpus (DirSource("C:\\Users\\kavin_000\\Documents\\R_tmp"))
cards <- tm_map(cards, stripWhitespace)
cards <- tm_map(cards, toupper)
cards <- tm_map(cards, removeWords, stopwords("english"))
cards <- tm_map(cards, stemDocument)
cards <- tm_map(cards, PlainTextDocument)
cards <- tm_map(cards, removeWords, c("and", "the", "will"))
cards <- tm_map(cards, removeWords, "and")
wordcloud(cards, scale=c(5,0.5), min.freq=10, max.words=100, random.order=FALSE, rot.per=0.35, use.r.layout=FALSE, colors=brewer.pal(8, "Dark2"))
Errors faced:
| Error | Fix |
| Error: inherits(doc, "TextDocument") is not TRUE | lords <- tm_map(lords, PlainTextDocument) |
| Error: could not find function "wordcloud" | install.packages("wordcloud") library("wordcloud") |
| Error in loadNamespace(name) : there is no package called ‘SnowballC’ | install.packages("SnowballC") |
| Error: could not find function "Corpus" | library(tm) |
| Error: '\U' used without hex digits in character string starting ""C:\U | replace all the \ with \\ |
What to do next?
- remove and, the, for, etc ...
- how to add them to stopwords
Reference:
https://georeferenced.wordpress.com/2013/01/15/rwordcloud/
No comments:
Post a Comment