Generating a word cloud
In this recipe, we will study how to quickly generate a word cloud in R. A word cloud is simply a graphical representation in which the size of the font used for the word corresponds to its frequency relative to others. Bigger the size of the word, higher is its frequency. Color, in this recipe, does not have any interpretation. In this recipe, the text is not formatted or processed using techniques such as stemming or by removal of stop words. We will study these text processing techniques in the next recipe.
Getting ready
In order to generate a simple word cloud, we will use the following libraries in R:
wordcloud
tm
RColorBrewer
How to do it…
In order to generate a simple word cloud, we will first install the necessary packages in R using the install.packages()
and library()
functions:
install.packages(c("wordcloud","RColorBrewer")) library(wordcloud) library(RColorBrewer)
The RColorBrewer
package provides us with a range of color palettes that can be used via the...