# Install packages
if (!requireNamespace("ggwordcloud", quietly = TRUE)) {
install.packages("ggwordcloud")
}
# Load packages
library(ggwordcloud)
ggwordcloud
The word cloud is to visualize the โkeywordsโ that appear frequently in the web text by forming a โkeyword cloud layerโ or โkeyword renderingโ.
Setup
System Requirements: Cross-platform (Linux/MacOS/Windows)
Programming language: R
Dependent packages:
ggwordcloud
Data Preparation
Load data nouns and noun frequencies.
# Load data
<- read.delim("files/Hiplot/076-ggwordcloud-data.txt", header = T)
data <- "files/Hiplot/076-ggwordcloud-hearth.png"
inmask
# Convert data structure
<- data[, 2]
col <- cbind(data, col)
data
# View data
head(data)
word freq col
1 oil 85 85
2 said 73 73
3 prices 48 48
4 opec 42 42
5 mln 31 31
6 the 26 26
Visualization
# ggwordcloud
<- ggplot(data, aes(label = word, size = freq, color = col)) +
p scale_size_area(max_size = 40) +
theme_minimal() +
geom_text_wordcloud_area(mask = png::readPNG(inmask), rm_outside = TRUE) +
scale_color_gradient(low = "#8B0000", high = "#FF0000")
p

Display the proportion of nouns in the word cloud graph according to the frequency of nouns.