

If(!colorPalette %in% rownames()) colors = colorPaletteĮlse colors = brewer.pal(8, colorPalette) If(textStemming) docs <- tm_map(docs, stemDocument) TextStemming=FALSE, colorPalette="Dark2",Įlse if(type="url") text <- html_to_text(x)ĭocs <- tm_map(docs, content_transformer(tolower))ĭocs <- tm_map(docs, removeWords, stopwords(lang))ĭocs <- tm_map(docs, removeWords, excludeWords) Rquery.wordcloud <- function(x, type=c("text", "url", "file"), # value returned by the function : a list(tdm, freqTable) # max.words : Maximum number of words to be plotted. # min.freq : words with frequency below min.freq will not be plotted # colorPalette : the name of color palette taken from RColorBrewer package, # textStemming : reduces words to their root form # excludeWords : a vector of words to exclude from the text # type : specify whether x is a plain text, a web page url or a file path

# x : character string (plain text, web url, txt file path)
3d word cloud generator generator#
# rquery.wordcloud() : Word cloud generator The above image clearly shows that “Will”, “freedom”, “dream”, “day” and “together” are the five most frequent words in Martin Luther King “ I have a dream speech”. Res<-rquery.wordcloud(filePath, type ="file", lang = "english", max.words : maximum number of words to be plotted.Res<-rquery.wordcloud(filePath, type ="file", lang = "english")Ĭhange the arguments max.words and min.freq to plot more words :
3d word cloud generator code#
Generate the word cloud using the R code below : source('')

It works with local and online hosted txt filesĬreating word clouds requires at least five main text-mining steps (described in my previous post). This function can be used to create a word cloud from different sources including : The goal of this tutorial is to provide a simple word cloud generator function in R programming language.

3d word cloud generator software#
The procedure to generate a word cloud using R software has been described in my previous post available here : Text mining and word cloud fundamentals in R : 5 simple steps you should know.
