This is an introduction to wordcloud2 package. This package provides an HTML5 interface to wordcloud for data visualization. Timdream’s wordcloud2.js is used in this package. png

This document show two main function in Wordcloud2:

  1. wordcloud2: provide traditional wordcloud with HTML5
  2. letterCloud: provide wordcloud with selected word(letters).

install wordcloud2

You may have installed this package. Well, I still want to leave these codes here for installing.

require(devtools)
install_github("lchiffon/wordcloud2")

wordlcoud2 function

You can use wordcloud directly:

library(wordcloud2)
wordcloud2(data = demoFreq)

demoFreq is a data.frame including word and freq in each column.

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

Parameters

Example1: use color and backgroundcolor

wordcloud2(demoFreq, color = "random-light", backgroundColor = "grey")