Learn R Programming

quickOutlier (version 0.1.0)

plot_outliers: Plot Outliers with ggplot2

Description

Visualizes the distribution of a variable and highlights detected outliers in red. It combines a boxplot (for context) and jittered points (for individual data visibility).

Usage

plot_outliers(data, column, method = "zscore", threshold = 3)

Value

A ggplot object. You can add more layers to it using +.

Arguments

data

A data frame.

column

The name of the numeric column to plot.

method

"zscore" or "iqr". Defaults to "zscore".

threshold

Numeric. Defaults to 3 for zscore, 1.5 for IQR.

Examples

Run this code
library(ggplot2)
df <- data.frame(val = c(rnorm(50), 10)) # 50 normal points and one outlier
plot_outliers(df, "val", method = "iqr")

Run the code above in your browser using DataLab