textplot_terms: Plot polarity scores of words

View source: R/textplot.R

textplot_termsR Documentation

Plot polarity scores of words

Description

Plot polarity scores of words

Usage

textplot_terms(
  x,
  highlighted = NULL,
  max_highlighted = 50,
  max_words = 1000,
  sampling = c("absolute", "relative"),
  ...
)

Arguments

x

a fitted textmodel_lss object.

highlighted

quanteda::pattern to select words to highlight. If a quanteda::dictionary is passed, words in the top-level categories are highlighted in different colors.

max_highlighted

the maximum number of words to highlight. When highlighted = NULL, words are randomly sampled proportionally to beta ^ 2 * log(frequency) for highlighting.

max_words

the maximum number of words to plot. Words are randomly sampled to keep the number below the limit.

sampling

if "relative", words are sampled based on their squared deviation from the mean for highlighting; if "absolute", they are sampled based on the squared distance from zero.

...

passed to underlying functions. See the Details.

Details

Users can customize the plots through ..., which is passed to ggplot2::geom_text() and ggrepel::geom_text_repel(). The colors are specified internally but users can override the settings by appending ggplot2::scale_colour_manual() or ggplot2::scale_colour_brewer(). The legend title can also be modified using ggplot2::labs().


koheiw/LSX documentation built on June 12, 2025, 10:55 p.m.