Book Image

R Data Visualization Cookbook

Book Image

R Data Visualization Cookbook

Overview of this book

Table of Contents (17 chapters)
R Data Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...