diagnose_outlier | R Documentation |
The diagnose_outlier() produces outlier information for diagnosing the quality of the numerical data.
diagnose_outlier(.data, ...)
## S3 method for class 'data.frame'
diagnose_outlier(.data, ...)
## S3 method for class 'grouped_df'
diagnose_outlier(.data, ...)
.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. |
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.
an object of tbl_df.
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.
diagnose_outlier.tbl_dbi
, diagnose.data.frame
, diagnose_category.data.frame
, diagnose_numeric.data.frame
.
# 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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.