Skip to contents

Shows the distribution of a numeric variable (optionally by group) as a box and/or violin plot, with points beyond the 1.5 * IQR fences highlighted so that outliers are easy to spot before modelling.

Usage

outlier_plot(
  data,
  y,
  group = NULL,
  type = c("box", "violin", "both"),
  flag = TRUE,
  outlier_colour = depictr_accent(),
  palette = NULL,
  title = NULL,
  y_lab = NULL
)

Arguments

data

A data frame.

y

The numeric variable (string or unquoted name).

group

Optional grouping variable on the x-axis.

type

One of "box", "violin" or "both".

flag

Whether to highlight outliers (points beyond 1.5 * IQR).

outlier_colour

Colour for highlighted outliers.

palette

Colours for the groups; defaults to depictr_palette().

title, y_lab

Plot title and value-axis label.

Value

A ggplot2::ggplot object.

Examples

outlier_plot(crop_yield, yield)

outlier_plot(lexical_decision, RT, group = condition, type = "both")