vignettes/wordcloud.md

title: "Wordcloud2 introduction" date: "r Sys.Date()" output: html_document: highlight: kate toc: true toc_depth: 4 mathjax: null

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. ```{r eval = F} devtools::install_github("lchiffon/wordcloud2")


### `wordlcoud2` function

You can use wordcloud directly:
```{r eval= F}
library(wordcloud2)
wordcloud2(data = demoFreq)

ex0

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

```{r eval = F} head(demoFreq)

```{r eval = F}
         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

```{r eval = F} wordcloud2(demoFreq, color = "random-light", backgroundColor = "grey")

![png](http://7xr5em.com1.z0.glb.clouddn.com/ex1.png)

#### Example2: use rotations

```{r}
wordcloud2(demoFreq, minRotation = -pi/6, maxRotation = -pi/6, minSize = 10,
  rotateRatio = 1)

png

Example3: use figure file as a mask.

For example, t.png is A BIRD with black and white: png

```{r eval = F} figPath = system.file("examples/t.png",package = "wordcloud2") wordcloud2(demoFreq, figPath = figPath, size = 1.5,color = "skyblue")

![png](http://7xr5em.com1.z0.glb.clouddn.com/tcloud.png)

### `letterCloud` function 

`letterCloud` provide the function to create a wordcloud with a word, like this:
```{r eval = F}
letterCloud(demoFreq, word = "R", size = 2)

png

Or: {r eval = F} letterCloud(demoFreq, word = "WORDCLOUD2", wordSize = 1) png wordcloud with fig and letterCloud may disappeared in Rstudio Viewer, open into browser when you meet this bug

Parameters



Try the wordcloud2 package in your browser

Any scripts or data that you put into this service are public.

wordcloud2 documentation built on May 1, 2019, 7:16 p.m.