Learn R Programming

dlookr (version 0.5.0)

univar_numeric: Statistic of univariate numerical variables

Description

The univar_numeric() calculates statistic of numerical variables that is frequency table

Usage

univar_numeric(.data, ...)

# S3 method for data.frame univar_numeric(.data, ...)

Arguments

.data

a data.frame or a tbl_df.

...

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. These arguments are automatically quoted and evaluated in a context where column names represent column positions. They support unquoting and splicing.

Value

An object of the class as individual variables based list. A component named "statistics" is a tibble object with the following statistics.:

  • variable : factor. The level of the variable. 'variable' is the name of the variable.

  • n : number of observations excluding missing values

  • na : number of missing values

  • mean : arithmetic average

  • sd : standard deviation

  • se_mean : standrd error mean. sd/sqrt(n)

  • IQR : interquartile range (Q3-Q1)

  • skewness : skewness

  • kurtosis : kurtosis

  • median : median. 50% percentile

Attributes of return object

Attributes of compare_category class is as follows.

  • raw : a data.frame or a tbl_df. Data containing variables to be compared. Save it for visualization with plot.univar_numeric().

  • variables : character. List of variables selected for calculate statistics.

Details

univar_numeric() calculates the popular statistics of numerical variables. If a specific variable name is not specified, statistics for all categorical numerical included in the data are calculated. The statistics obtained by univar_numeric() are part of those obtained by describe(). Therefore, it is recommended to use describe() to simply calculate statistics. However, if you want to visualize the distribution of individual variables, you should use univar_numeric().

See Also

summary.univar_numeric, print.univar_numeric, plot.univar_numeric.

Examples

Run this code
# NOT RUN {
# Calculates the all categorical variables
all_var <- univar_numeric(heartfailure)

# Print univar_numeric class object
all_var

# Calculates the platelets, sodium variable
univar_numeric(heartfailure, platelets, sodium)

# Summary the all case : Return a invisible copy of an object.
stat <- summary(all_var)

# Summary by returned object
stat

# Statistics of numerical variables normalized by Min-Max method
summary(all_var, stand = "minmax")

# Statistics of numerical variables standardized by Z-score method
summary(all_var, stand = "zscore")

# one plot with all variables
# plot(all_var)

# one plot with all normalized variables by Min-Max method
# plot(all_var, stand = "minmax")

# one plot with all variables
# plot(all_var, stand = "none")

# one plot with all robust standardized variables 
# plot(all_var, viz = "boxplot")

# one plot with all standardized variables by Z-score method 
# plot(all_var, viz = "boxplot", stand = "zscore")

# individual boxplot by variables
# plot(all_var, indiv = TRUE, "boxplot")

# individual histogram by variables
# plot(all_var, indiv = TRUE, "hist")

# individual histogram by robust standardized variable 
# plot(all_var, indiv = TRUE, "hist", stand = "robust")

# plot all variables by prompt
# plot(all_var, indiv = TRUE, "hist", prompt = TRUE)

# }

Run the code above in your browser using DataLab