Modelwordcloud

Modelwordcloud is a package that makes a word cloud out of text, primarially based on the associations between that text and a predictive model.

```{R, eval=TRUE} data(iris) model <- lm(Petal.Width ~ Species, iris) summary(model)

As we can see, setosa (represented by the intercept) is the least associated with Petal.Width, wheras virginica is the most associated.

We can show this in a word cloud:

```{R, eval=TRUE}
words_and_freqs <- rle(as.character(iris$Species))
freqs <- words_and_freqs$lengths
words <- words_and_freqs$values
coefficients <- model$coefficients
colors <- c("red", "orange", "blue")  # Least associated gets red, most associated gets blue.
library(modelwordcloud)
wordcloud(words = words, freq = freqs, coefficients = coefficients, colors = colors)

You can also pass in the model object directly, if desired.

```{R, eval=TRUE} wordcloud(model, colors = colors)

## Installation

This package can be installed from CRAN:

```R
install.packages("modelwordcloud")

Acknowledgements

This work is based upon the wordcloud package by Ian Fellows, available from CRAN with the LGPL-2.1 license. This derivative work modified the original wordcloud package library by adding in logic to color words based on an additional variable, coefficients. The code was also cleaned, re-styled, and simplified. This package also removed some unneeded functionality from the wordcloud package, such as a C library for calculating overlap.

See Also



peterhurford/modelwordcloud documentation built on Sept. 8, 2017, 1:56 p.m.