# 安装包
if (!requireNamespace("d3wordcloud", quietly = TRUE)) {
::install_github("jbkunst/d3wordcloud")
devtools
}
# 加载包
library(d3wordcloud)
D3 词云
文云文本展示。
环境配置
系统: Cross-platform (Linux/MacOS/Windows)
编程语言: R
依赖包:
d3wordcloud
数据准备
# 加载数据
<- read.delim("files/Hiplot/036-d3-wordcloud-data.txt", header = T)
data
# 整理数据格式
row.names(data) <- data[, 1]
# 查看数据
head(data)
word freq
oil oil 85
said said 73
prices prices 48
opec opec 42
mln mln 31
the the 26
可视化
# D3 词云
<- d3wordcloud(
p words = data[, 1],
freqs = data[, 2],
padding = 0,
rotate.min = 0,
rotate.max = 0,
size.scale = "linear",
color.scale = "linear",
spiral = "archimedean",
font = "Arial",
rangesizefont = c(10, 90)
)
p