R Code Assignment | Homework For You
February 18th, 2020
I’m writing a r code to produce a word cloud from “alice.txt”. I need to remove all the punctuations and also add a title. I tried but my word cloud still has punctuation and the title doesn’t show. Is anyone know how to fix it? Thank you for your help.
library(“tm”) library(“SnowballC”) library(“wordcloud”) library(“RColorBrewer”) text <- readLines(file.choose()) docs <- Corpus (VectorSource(text)) inspect(docs) toSpace <- content_transformer(function (x, pattern ) gsub(pattern, ” “, x)) docs <- tm_map(docs, toSpace, “/”) docs <- tm_map(docs, toSpace, “@”) docs <- tm_map(docs, toSpace, “\\\”) docs <- tm_map(docs, content_transformer(tolower)) docs <- tm_map(docs, removeNumbers) docs <- tm_map(docs, removeWords, stopwords(“english”)) docs <- tm_map(docs, removePunctuation) docs <- tm_map(docs, stripWhitespace) docs <- tm_map(docs, stemDocument) wordcloud(words = docs, max.words=20, random.order=FALSE, rot.per=0.35, random.color = FALSE, colors = c(“indianred1″,”indianred2″,”indianred3″,”indianred”), main = “Alice in Wonderland”) Get Computer Science homework help today