我刚刚尝试使用wordcloud2
创建包含在Africa continent中的wordcloud,但看不到图像中的单词。
library(wordcloud2)
cloud <- data.frame(
word = c(
"Atlantic",
"Coho",
"Rainbow",
"Arctic",
"Chinook",
"Danube",
"Grayling"
),
freq = c(
6,
7,
9,
10,
3,
9,
2
))
wordcloud2(data = cloud,
figPath = "africa3.png"
)
我以某种方式解决了这个问题,但是这些单词在image中并不适合。有人可以改善以下代码:
myFun <- function(n = 5000) {
a <- do.call(paste0, replicate(5, sample(LETTERS, n, TRUE), FALSE))
paste0(a, sprintf("%04d", sample(9999, n, TRUE)), sample(LETTERS, n, TRUE))
}
cloud <- data.frame(
word = myFun(100),
freq = sample(30, size = 100, replace = TRUE))
wordcloud2(data = cloud, figPath = "africa4.png",color = "skyblue",shuffle = F, size = 0.5, ellipticity = 1.5)