Wordcloud visualisation - changing image

I'm trying to generate a wordcloud using Twitter's logo does anyone know how i'd implement this? Below is the code i'm using and the very end is the code I've tried to come up for the new wordcloud but been unsuccessful.

.libPaths("M:/R")
library(SnowballC)
library(wordcloud)
library(RColorBrewer)
library(tm)
library(utils)
library(wordcloud2)

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, removeNumbers)
docs <- tm_map(docs, removeWords, stopwords("english"))
docs <- tm_map(docs, removePunctuation)
docs <- tm_map(docs, stripWhitespace)
docs <- tm_map(docs, content_transformer(tolower))

dtm <- TermDocumentMatrix(docs)
m <- as.matrix(dtm)
v <- sort(rowSums(m), decreasing = TRUE)
d <- data.frame(word = names(v),freq=v)
head(d,10)

set.seed(1234)
wordcloud(words = d$word, freq = d$freq, min.freq = 1, max.words = 200, random.order = FALSE, rot.per=0.35,colors=brewer.pal(8, "Paired"))

figPath = system.file("examples/t.png",package = "wordcloud")
wordcloud(docs, figPath = figPath, size = 1.5,color = "skyblue")

Hi @dataanalyst09 - admittingly I have never done this before, but does this post help you? It suggests using wordcloud2.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.