Learn R Programming

quanteda (version 0.99)

textplot_keyness: plot word keyness

Description

Plot the results of a "keyword" of features comparing their differential associations with a target and a reference group, after calculating keyness using textstat_keyness.

Usage

textplot_keyness(x, show_reference = TRUE, n = 20L, min_count = 2L)

Arguments

x

a return object from textstat_keyness

show_reference

logical; if TRUE, show key reference features in addition to key target features

n

integer; number of features to plot

min_count

numeric; minimum total count of feature across the target and reference categories, for a feature to be included in the plot

Value

a ggplot2 object

See Also

textstat_keyness

Examples

Run this code
# NOT RUN {
# compare Trump v. Obama speeches
prescorpus <- corpus_subset(data_corpus_inaugural, 
                            President %in% c("Obama", "Trump"))
presdfm <- dfm(prescorpus, groups = "President", remove = stopwords("english"),
               remove_punct = TRUE)
result <- textstat_keyness(presdfm, target = "Trump")

# plot estimated word keyness
textplot_keyness(result) 
textplot_keyness(result, show_reference = FALSE)
# }

Run the code above in your browser using DataLab