Constructing a word cloud from a document

In the previous recipe, we studied a quick and easy way to generate a word cloud. In this recipe, we will learn how to create a word cloud using an entire document, such as a transcript of the complete inaugural speech by President Obama. We will also learn how to process the text and structure it using the text mining package.

Constructing a word cloud from a document

Getting ready

To generate a word cloud and structure our data, we will use the following packages:

  • wordcloud
  • tm

How to do it…

We will start this recipe by installing and loading the required packages in R using the install.packages() and library() functions:

install.packages(c("wordcloud","tm")) ...

Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.