Title: | Model Word Clouds |
Version: | 0.1 |
Author: | Peter Hurford [aut, cre] |
Maintainer: | Peter Hurford <peter.hurford@datarobot.com> |
Description: | Makes a word cloud of text, sized by the frequency of the word, and colored either by user-specified colors or colored by the strength of the coefficient of that text derived from a regression model. |
License: | LGPL-2.1 |
LazyData: | true |
Imports: | methods, graphics, stats |
RoxygenNote: | 6.0.1 |
Suggests: | testthat |
NeedsCompilation: | no |
Packaged: | 2017-09-07 02:37:50 UTC; peter.hurford |
Repository: | CRAN |
Date/Publication: | 2017-09-07 08:48:24 UTC |
Make a word cloud.
Description
Make a word cloud.
Usage
wordcloud(model_object = NULL, words = NULL, freq = NULL,
coefficients = NULL, colors = "black", scale = c(4, 0.5),
min_freq = 3, max_words = Inf, random_order = FALSE,
random_color = FALSE, rot_per = 0, bg_color = "#FFFFFF")
Arguments
model_object |
lm. A linear model object. If this is passed, words, freq, and coefficients can be derived and do not need to be passed. |
words |
character. A vector of words to plot. |
freq |
numeric. The frequency of those words. |
coefficients |
numeric. If provided, colors will be assigned according to coefficients. |
colors |
character. The colors to use for plotting. |
scale |
numeric. The range of sizes. |
min_freq |
numeric. Words with less frequency than this will not be plotted. |
max_words |
numeric. Don't plot more words than this amount. |
random_order |
logical. Should words be plotted in a random_order or by frequency (default FALSE)? |
random_color |
logical. Allocate words a color by random? (default FALSE). |
rot_per |
numeric. Amount of rotation to apply to each word, between 0 and 1. Defaults to 0 (no rotation). |
bg_color |
character. The color of the background. |
Examples
data(iris)
model <- lm(Petal.Width ~ Species, iris)
library(modelwordcloud)
colors <- c("red", "orange", "blue")
wordcloud(model, colors = colors)
words_and_freqs <- rle(as.character(iris$Species))
freqs <- words_and_freqs$lengths
words <- words_and_freqs$values
coefficients <- model$coefficients
wordcloud(words = words, freq = freqs, coefficients = coefficients, colors = colors)