diagnose_numeric {dlookr} | R Documentation |
Diagnose data quality of numerical variables
Description
The diagnose_numeric() produces information for diagnosing the quality of the numerical data.
Usage
diagnose_numeric(.data, ...)
## S3 method for class 'data.frame'
diagnose_numeric(.data, ...)
## S3 method for class 'grouped_df'
diagnose_numeric(.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_numeric() 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 calculate a statistic that can be used to understand the distribution of numerical data. min, Q1, mean, median, Q3, max can be used to estimate the distribution of data. If the number of zero or minus is large, it is necessary to suspect the error of the data. If the number of outliers is large, a strategy of eliminating or replacing outliers is needed.
Value
an object of tbl_df.
Numerical diagnostic information
The information derived from the numerical data diagnosis is as follows.
variables : variable names
min : minimum
Q1 : 25 percentile
mean : arithmetic average
median : median. 50 percentile
Q3 : 75 percentile
max : maximum
zero : count of zero values
minus : count of minus values
outlier : count of outliers
See vignette("diagonosis") for an introduction to these concepts.
See Also
diagnose_numeric.tbl_dbi
, diagnose.data.frame
, diagnose_category.data.frame
, diagnose_outlier.data.frame
.
Examples
# Diagnosis of numerical variables
diagnose_numeric(heartfailure)
# Select the variable to diagnose
diagnose_numeric(heartfailure, cpk_enzyme, sodium)
diagnose_numeric(heartfailure, -cpk_enzyme, -sodium)
diagnose_numeric(heartfailure, "cpk_enzyme", "sodium")
diagnose_numeric(heartfailure, 5)
# Using pipes ---------------------------------
library(dplyr)
# Diagnosis of all numerical variables
heartfailure %>%
diagnose_numeric()
# Positive values select variables
heartfailure %>%
diagnose_numeric(cpk_enzyme, sodium)
# Negative values to drop variables
heartfailure %>%
diagnose_numeric(-cpk_enzyme, -sodium)
# Positions values select variables
heartfailure %>%
diagnose_numeric(5)
# Negative values to drop variables
heartfailure %>%
diagnose_numeric(-1, -5)
# Using pipes & dplyr -------------------------
# List of variables containing outliers
heartfailure %>%
diagnose_numeric() %>%
filter(outlier > 0)
# Using group_by ------------------------------
# Calculate the diagnosis of all variables by 'death_event' using group_by()
heartfailure %>%
group_by(death_event) %>%
diagnose_numeric()