Skip to contents

Show type-token ratio over time

Usage

plot_ttr(
  data,
  x = progress,
  by = doc_id,
  identity = NULL,
  descriptive_labels = TRUE,
  labeling = c("point", "inline", "inset"),
  log_y = TRUE
)

Arguments

data

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

x

A column showing the cumulative progress of documents

by

A grouping column for colors and labels

identity

A grouping column for lines

descriptive_labels

A toggle for disabling descriptive labels of progress_percent on the X-axis

labeling

Options for labeling groups:

  • "point" labels the final value

  • "inline" prints the label within a smoothed curve

  • "inset" prints a legend within the plot area

  • Anything else prints a legend to the right of the plot area.

log_y

A toggle for logarithmic scaling to the Y-axis; defaults to TRUE

Value

A ggplot object

Examples

if (FALSE) { # \dontrun{
dubliners <- get_gutenberg_corpus(2814) |>
  load_texts() |>
  identify_by(part) |>
  standardize_titles()

dubliners_measured <- dubliners |>
  add_vocabulary()

dubliners_measured |>
  plot_ttr(labeling = "inline")

dubliners_measured |>
  plot_ttr()
} # }