Learn R Programming

quanteda (version 0.7.2-1)

plot.dfm: plot features as a wordcloud

Description

The default plot method for a dfm object. Produces a wordcloud plot for the features of the dfm, weighted by the total frequencies. To produce word cloud plots for specific documents, the only way currently to do this is to produce a dfm only from the documents whose features you want plotted.

Usage

## S3 method for class 'dfm':
plot(x, ...)

Arguments

x
a dfm object
...
additional parameters passed to to wordcloud or to text (and strheight, strwidth)

See Also

wordcloud

Examples

Run this code
# plot the features (without stopwords) from Obama's two inaugural addresses
mydfm <- dfm(subset(inaugCorpus, President=="Obama"), verbose=FALSE,
             ignoredFeatures=stopwords("english"))
plot(mydfm)

# plot only Lincoln's inaugural address
plot(dfm(subset(inaugCorpus, President=="Lincoln"), verbose=FALSE,
     ignoredFeatures=stopwords("english")))

# plot in colors with some additional options passed to wordcloud
plot(mydfm, random.color=TRUE, rot.per=.25, colors=sample(colors()[2:128], 5))

Run the code above in your browser using DataLab