diagnose_outlier {dlookr} | R Documentation |
Diagnose outlier of numerical variables
Description
The diagnose_outlier() produces outlier information for diagnosing the quality of the numerical data.
Usage
diagnose_outlier(.data, ...)
## S3 method for class 'data.frame'
diagnose_outlier(.data, ...)
## S3 method for class 'grouped_df'
diagnose_outlier(.data, ...)
Arguments
.data |
a data.frame or a |
... |
one or more unquoted expressions separated by commas. You can treat variable names like they are positions. Positive values select variables; negative values to drop variables. If the first expression is negative, diagnose_outlier() will automatically start with all variables. These arguments are automatically quoted and evaluated in a context where column names represent column positions. They support unquoting and splicing. |
Details
The scope of the diagnosis is the provide a outlier information. If the number of outliers is small and the difference between the averages including outliers and the averages not including them is large, it is necessary to eliminate or replace the outliers.
Value
an object of tbl_df.
Outlier Diagnostic information
The information derived from the numerical data diagnosis is as follows.
variables : variable names
outliers_cnt : number of outliers
outliers_ratio : percent of outliers
outliers_mean : arithmetic average of outliers
with_mean : arithmetic average of with outliers
without_mean : arithmetic average of without outliers
See vignette("diagonosis") for an introduction to these concepts.
See Also
diagnose_outlier.tbl_dbi
, diagnose.data.frame
, diagnose_category.data.frame
, diagnose_numeric.data.frame
.
Examples
# Diagnosis of numerical variables
diagnose_outlier(heartfailure)
# Select the variable to diagnose
diagnose_outlier(heartfailure, cpk_enzyme, sodium)
diagnose_outlier(heartfailure, -cpk_enzyme, -sodium)
diagnose_outlier(heartfailure, "cpk_enzyme", "sodium")
diagnose_outlier(heartfailure, 5)
# Using pipes ---------------------------------
library(dplyr)
# Diagnosis of all numerical variables
heartfailure %>%
diagnose_outlier()
# Positive values select variables
heartfailure %>%
diagnose_outlier(cpk_enzyme, sodium)
# Negative values to drop variables
heartfailure %>%
diagnose_outlier(-cpk_enzyme, -sodium)
# Positions values select variables
heartfailure %>%
diagnose_outlier(5)
# Negative values to drop variables
heartfailure %>%
diagnose_outlier(-1, -5)
# Using pipes & dplyr -------------------------
# outlier_ratio is more than 1%
heartfailure %>%
diagnose_outlier() %>%
filter(outliers_ratio > 1)
# Using group_by ------------------------------
# Calculate the diagnosis of all variables by 'death_event' using group_by()
heartfailure %>%
group_by(death_event) %>%
diagnose_outlier()