WordPress WordCloud with R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
These days one can frequently read about wordclouds created with R, initiated by the release of the wordcloud package by Ian Fellows on July 23rd. So here I am to put in my two cents.
I thought about creating a wordcloud of a complete blog history, so I build a script that connects to a MySQL database and grabs all published posts and pages. All articles are combined in an huge text, that, when purged from tags and special chars, is visualized as a wordcloud:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
library(RMySQL)
require(wordcloud) require(RColorBrewer) # special chars we want to delete # connect to your DB # replace all unwanted stuff # remove words with _bad_ chars (non utf-8 stuff) # create the image |
Enough code, here is the result for my slight blog:
Smart image, isn’t it? Unfortunately it takes about 30 secs to generate it, otherwise it would be cool to create such a cloud live with for example rApache.
R: wordpress-wordcloud.R
(Please take a look at the man-page. Browse bugs and feature requests.)
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.