D3 Wordcloud

Authors

[Editor] Hu Zheng;

[Contributors]

Display the wordcloud。

Setup

  • System Requirements: Cross-platform (Linux/MacOS/Windows)

  • Programming language: R

  • Dependent packages: d3wordcloud

# Install packages
if (!requireNamespace("d3wordcloud", quietly = TRUE)) {
  devtools::install_github("jbkunst/d3wordcloud")
}

# Load packages
library(d3wordcloud)

Data Preparation

# Load data
data <- read.delim("files/Hiplot/036-d3-wordcloud-data.txt", header = T)

# convert data structure
row.names(data) <- data[, 1]

# View data
head(data)
         word freq
oil       oil   85
said     said   73
prices prices   48
opec     opec   42
mln       mln   31
the       the   26

Visualization

# D3 Wordcloud
p <- d3wordcloud(
  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
FigureΒ 1: D3 Wordcloud