Learn R Programming

quickOutlier (version 0.1.5)

detect_categorical_outliers: Detect Rare Categories (Categorical Outliers)

Description

Identifies categories in a character or factor vector that appear less frequently than a specified threshold.

Usage

detect_categorical_outliers(data, min_freq = 0.01)

Value

A data frame summarizing the categories:

Category

The name of the level.

Count

Absolute frequency.

Frequency

Relative frequency.

Is_Outlier

Logical flag.

Arguments

data

A vector (character or factor).

min_freq

Numeric. The minimum percentage (0 to 1) required to be considered normal. Defaults to 0.01 (1 percent).

Details

The function calculates the relative frequency of each unique level. If the frequency is below min_freq, the category is flagged as an outlier.

Examples

Run this code
cities <- c(rep("Madrid", 10), "Barcalona")
detect_categorical_outliers(cities, min_freq = 0.1)

Run the code above in your browser using DataLab