View source: R/find_outliers.R
find_outliers | R Documentation |
Identifies statistical outliers in a numeric variable using the Interquartile Range (IQR) method. Provides detailed diagnostics about the outlier detection process.
find_outliers(data, variable_name, verbose = TRUE)
data |
Data frame containing the variable to analyze. |
variable_name |
Unquoted name of the numeric variable to check for outliers. |
verbose |
Logical. If TRUE, prints diagnostic information about quartiles, fences, and number of outliers found. Default is TRUE. |
The function uses the standard IQR method for outlier detection:
Calculates Q1 (25th percentile) and Q3 (75th percentile)
Computes IQR = Q3 - Q1
Defines outliers as values outside (Q1 - 1.5IQR, Q3 + 1.5IQR)
If outliers are found:
Data frame containing rows with outlier values
Prints diagnostic information about quartiles and fences
If no outliers:
Returns NULL
Prints confirmation message
Variable name
Q1 and Q3 values
IQR value
Upper and lower fence values
Number of outliers found
data(mtcars)
find_outliers(mtcars, mpg)
find_outliers(mtcars, wt, verbose = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.