make_wordcloud {inlpubs} | R Documentation |
Create Word Cloud
Description
Create a word cloud from a frequency table of words, and save to a PNG file.
Requires R-packages htmltools, htmlwidgets, magick, webshot2,
and wordcloud2 are available.
System dependencies include the the following:
ImageMagick for displaying the PNG image,
OptiPNG for PNG file compression, and
Chrome- or a Chromium-based browser
with support for the Chrome DevTools protocol.
Use find_chromate
function to find the path to the Chrome browser.
Usage
make_wordcloud(
x,
max_terms = 200,
size = 1,
shape = "circle",
ellipticity = 0.65,
...,
width = 910,
output = NULL,
display = FALSE
)
Arguments
x |
'data.frame'. A frequency table of terms that includes "term" and "freq" in each column. |
max_terms |
'integer' number. Maximum number of terms to include in the word cloud. |
size |
'numeric' number. Font size. |
shape |
'character' string. Shape of the “cloud” to draw. Possible shapes include a "circle", "cardioid", "diamond", "triangle-forward", "triangle", "pentagon", and "star". |
ellipticity |
'numeric' number. Degree of “flatness” of the shape to draw, a value between 0 and 1. |
... |
Additional arguments to be passed to the |
width |
'integer' number. Desired image width in pixels. |
output |
'character' string. Path to the output file, by default the word cloud is copied to a temporary file. |
display |
'logical' flag. Whether to display the saved PNG file in a graphics window. Requires access to the magick package. |
Value
File path to the word cloud plot in PNG format.
Author(s)
J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
See Also
mine_text
function to perform a term frequency text analysis.
Examples
## Not run:
d <- wordcloud2::demoFreq |> head(n = 10)
colnames(d) <- c("term", "freq")
file <- make_wordcloud(d, display = interactive())
unlink(file)
## End(Not run)