wordcloud 娱乐一下

使用 wordcloud2 库绘制基于 HTML5 canvas 技术的 wordcloud 图。

示例(常用编程语言):

library('wordcloud2')
# library('wordcloud')
# library('stringr')

text <- scan('data.txt', character())
# Or using string directly
# text <- str_split(text, pattern='[\s\n]+')

# Count words, like: python
# sum(!is.na(match(a, 'Python')))

wordcloud2(table(text), shape='pentagon')
# Or the old wordcloud
# wordcloud(text, min.freq=1, random.order=F, scale=c(5, .5), color=rainbow(6))

数据文件:https://pan.baidu.com/s/1u0uSA4sC-GwD3qnzRUSJOQ (密码: r9e2)

作者: YanWen

Web 开发者

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google photo

You are commenting using your Google account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s