For each column whose resolved type is "numeric", applies up to two
outlier detection methods (combined with logical OR):
Z-score: values whose absolute Z-score exceeds
max_z_scoreare flagged.IQR fence: values below
Q1 - k * IQRor aboveQ3 + k * IQR(wherek = iqr_fence_multiplier) are flagged.
Both thresholds support per-column overrides via config$column_rules.
A column is skipped (PASS with a note) when neither threshold is configured
or when it has fewer than four parseable values.
Arguments
- df
A data frame with all columns as character vectors (as returned by
read_dataset).- config
Named list. Merged configuration as returned by
load_config.- types
Optional named character vector of pre-resolved column types; see
check_inferred_types.
Value
A list of dq_result objects, one per numeric column.
Status is "FAIL" when outliers are detected; "PASS"
otherwise. Returns an empty list if no numeric columns are found.
Examples
cfg_dir <- system.file("demonstrations/config", package = "dqcheckr")
cfg <- load_config("starwars_csv", config_dir = cfg_dir)
path <- system.file("demonstrations/data/starwars.csv", package = "dqcheckr")
df <- read_dataset(path, cfg)
check_outliers(df, cfg)
#> [[1]]
#> [[1]]$check_id
#> [1] "QC-15"
#>
#> [[1]]$check_name
#> [1] "Outlier detection"
#>
#> [[1]]$column
#> [1] "height"
#>
#> [[1]]$status
#> [1] "PASS"
#>
#> [[1]]$observed
#> [1] "No outlier threshold configured."
#>
#> [[1]]$threshold
#> [1] NA
#>
#> [[1]]$message
#> [1] "Column 'height': outlier check skipped (no threshold)."
#>
#>
#> [[2]]
#> [[2]]$check_id
#> [1] "QC-15"
#>
#> [[2]]$check_name
#> [1] "Outlier detection"
#>
#> [[2]]$column
#> [1] "mass"
#>
#> [[2]]$status
#> [1] "PASS"
#>
#> [[2]]$observed
#> [1] "No outlier threshold configured."
#>
#> [[2]]$threshold
#> [1] NA
#>
#> [[2]]$message
#> [1] "Column 'mass': outlier check skipped (no threshold)."
#>
#>
#> [[3]]
#> [[3]]$check_id
#> [1] "QC-15"
#>
#> [[3]]$check_name
#> [1] "Outlier detection"
#>
#> [[3]]$column
#> [1] "birth_year"
#>
#> [[3]]$status
#> [1] "PASS"
#>
#> [[3]]$observed
#> [1] "No outlier threshold configured."
#>
#> [[3]]$threshold
#> [1] NA
#>
#> [[3]]$message
#> [1] "Column 'birth_year': outlier check skipped (no threshold)."
#>
#>