qdap (version 2.4.1)

gradient_cloud: Gradient Word Cloud

Description

Produces a gradient word cloud colored by a binary grouping variable.

Usage

gradient_cloud(
  text.var,
  bigroup.var,
  rev.binary = FALSE,
  X = "red",
  Y = "blue",
  stem = FALSE,
  stopwords = NULL,
  caps = TRUE,
  caps.list = NULL,
  I.list = TRUE,
  random.order = FALSE,
  rot.per = 0,
  min.freq = 1,
  max.word.size = NULL,
  min.word.size = 0.5,
  breaks = 10,
  cloud.font = NULL,
  title = NULL,
  title.font = NULL,
  title.color = "black",
  title.padj = 0.25,
  title.location = 3,
  title.cex = NULL,
  legend.cex = 0.8,
  legend.location = c(0.025, 0.025, 0.25, 0.04),
  char2space = "~~"
)

Arguments

text.var

The text variable.

bigroup.var

A binary grouping variable.

rev.binary

logical. If TRUE the ordering of the binary levels of bigroup.var is reversed.

X

The first gradient color for variable X.

Y

The second gradient color for variable Y.

stem

logical. If TRUE the text.var will be stemmed.

stopwords

Words to exclude from the cloud. Words will be removed after determining proportional word usage.

caps

logical. If TRUE selected words will be capitalized.

caps.list

A vector of words to capitalize (caps must be TRUE).

I.list

logical. If TRUE capitalizes I words and contractions.

random.order

Plot words in random order. If FALSE, they will be plotted in decreasing frequency.

rot.per

Proportion words with 90 degree rotation.

min.freq

An integer value indicating the minimum frequency a word must appear to be included.

max.word.size

A size argument to control the minimum size of the words.

min.word.size

A size argument to control the maximum size of the words.

breaks

An integer describing the number of breaks (odd numbers will be rounded up).

cloud.font

The font family of the cloud text.

title

A character string used as the plot title.

title.font

The font family of the cloud title.

title.color

A character vector of length one corresponding to the color of the title.

title.padj

Adjustment for the title. For strings parallel to the axes, padj = 0 means right or top alignment, and padj = 1 means left or bottom alignment.

title.location

On which side of the plot (1=bottom, 2=left, 3=top, 4=right).

title.cex

Character expansion factor for the title. NULL and NA are equivalent to 1.0.

legend.cex

Character expansion factor for the legend. NULL and NA are equivalent to 1.0.

legend.location

A vector of length 4 denoting the lower left (x and y left) and upper right (x and y right) coordinates of the rectangle of colors in user coordinates.

char2space

A vector of characters to be turned into spaces.

Value

Plots a gradient word cloud and invisibly returns the dataframe used to make the cloud.

Details

Breaking is done using quantile. This will ensure a certain percentage of words will be colored at each bin.

See Also

trans_cloud, wordcloud, color.legend

Examples

Run this code
# NOT RUN {
DATA$state <- space_fill(DATA$state, c("is fun", "too fun", "you liar"))

gradient_cloud(DATA$state, DATA$sex, title="fun")
gradient_cloud(DATA$state, DATA$sex, title="fun", rev.binary = TRUE)
gradient_cloud(DATA$state, DATA$sex, title="fun", max.word.size = 5,
    min.word.size = .025)
    
with(mraja1, gradient_cloud(dialogue, died, stopwords = Top25Words, 
    rot.per = .5, title="Heatcloud", title.color="orange", title.cex=1.75))    
x <- with(subset(mraja1, fam.aff %in% qcv(cap, mont)), 
    gradient_cloud(dialogue, fam.aff))
head(x) 

## 2012 U.S. Presidential Debates
invisible(lapply(split(pres_debates2012, pres_debates2012$time), function(x) {
    x <- x[x$person %in% qcv(ROMNEY, OBAMA), ]
    dev.new()
    gradient_cloud(x$dialogue, x$person, 
        title = paste("Debate", char2end(x$time[1])),
        stopwords = BuckleySaltonSWL,
        X = "blue", Y = "red", 
        max.word.size = 2.2, 
        min.word.size = 0.55
    )
}))
        
# }

Run the code above in your browser using DataCamp Workspace