Constructing a correlation plot and a phrase tree
In the previous recipe, we learned how to create a comparison cloud, which allows us to study the differences or similarities between two documents. In the process, we generated the term document matrix. In this recipe, we will learn some important matrix functions that allow us to further conduct text analysis and also generate a correlation plot.
We will also learn how to generate a phrase tree or a word tree. Wattenberg and Viegas (2008) state that a word tree places a tree structure for the words that follow a particular search term and uses that structure to arrange those words spatially. At the time of writing this book, I was unable to find a package that would allow me to construct a word tree in R. Hence, I have used an external link to demonstrate it. The latest version of Google Charts allows you to generate a word tree; however, the googleVis
package in R does not.
Getting ready
To generate a correlation plot, we will use the following...