Skip to contents

Plot a heatmap of ranked features

Usage

plot_doc_word_heatmap(
  df,
  rows = 1:10,
  by = doc_id,
  feature = word,
  label = TRUE
)

Arguments

df

A tidy data frame, potentially containing columns called "doc_id" and "word"

rows

The ranks to show, not counting ties

by

The column used for document grouping, with doc_id as the default

feature

The column to measure, as in "word" or "lemma"

label

Whether to show the rank as a label in the heatmap

Value

A ggplot object

Examples

dubliners <- get_gutenberg_corpus(2814) |>
  load_texts(lemma = TRUE) |>
  identify_by(part) |>
  standardize_titles()

# Make a smaller example
selected_titles <-
  c("The Sisters", "An Encounter", "Araby",
    "Counterparts", "The Dead")

dubliners |>
  dplyr::filter(doc_id %in% selected_titles) |>
  plot_doc_word_heatmap()


dubliners |>
  dplyr::filter(doc_id %in% selected_titles) |>
  plot_doc_word_heatmap(feature = lemma, rows = 1:6)