print and summary method for "univar_numeric" class.

# S3 method for univar_numeric
summary(object, stand = c("robust", "minmax", "zscore"), ...)

# S3 method for univar_numeric
print(x, ...)

Arguments

object

an object of class "univar_numeric", usually, a result of a call to univar_numeric().

stand

character Describe how to standardize the original data. "robust" normalizes the raw data through transformation calculated by IQR and median. "minmax" normalizes the original data using minmax transformation. "zscore" standardizes the original data using z-Score transformation. The default is "robust".

...

further arguments passed to or from other methods.

x

an object of class "univar_numeric", usually, a result of a call to univar_numeric().

Value

An object of the class as indivisual variabes based list. The statistics returned by summary.univar_numeric() are different from the statistics returned by univar_numeric(). univar_numeric() is the statistics for the original data, but summary. univar_numeric() is the statistics for the standardized data. 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 : standard error mean. sd/sqrt(n)

  • IQR : interquartile range (Q3-Q1)

  • skewness : skewness

  • kurtosis : kurtosis

  • median : median. 50% percentile

Details

print.univar_numeric() displays only the information of variables included in univar_numeric The "variables" attribute is not displayed.

Examples

# \donttest{
# Calculates the all categorical variables
all_var <- univar_numeric(heartfailure)

# Print univar_numeric class object
all_var
#> $statistics
#> # A tibble: 7 × 10
#>   described_variables     n    na      mean       sd   se_mean     IQR skewness
#>   <chr>               <int> <int>     <dbl>    <dbl>     <dbl>   <dbl>    <dbl>
#> 1 age                   299     0     60.8     11.9     0.688     19      0.424
#> 2 cpk_enzyme            299     0    582.     970.     56.1      466.     4.46 
#> 3 ejection_fraction     299     0     38.1     11.8     0.684     15      0.555
#> 4 platelets             299     0 263358.   97804.   5656.     91000      1.46 
#> 5 creatinine            299     0      1.39     1.03    0.0598     0.5    4.46 
#> 6 sodium                299     0    137.       4.41    0.255      6     -1.05 
#> 7 time                  299     0    130.      77.6     4.49     130      0.128
#> # ℹ 2 more variables: kurtosis <dbl>, median <dbl>
#> 

# Calculates the platelets, sodium variable
univar_numeric(heartfailure, platelets, sodium)
#> $statistics
#> # A tibble: 2 × 10
#>   described_variables     n    na    mean     sd se_mean   IQR skewness kurtosis
#>   <chr>               <int> <int>   <dbl>  <dbl>   <dbl> <dbl>    <dbl>    <dbl>
#> 1 platelets             299     0 263358. 9.78e4 5.66e+3 91000     1.46     6.21
#> 2 sodium                299     0    137. 4.41e0 2.55e-1     6    -1.05     4.12
#> # ℹ 1 more variable: median <dbl>
#> 

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

# Summary by returned object
stat
#> # A tibble: 7 × 8
#>   described_variables     mean    sd se_mean   IQR skewness kurtosis median
#>   <chr>                  <dbl> <dbl>   <dbl> <dbl>    <dbl>    <dbl>  <dbl>
#> 1 age                  0.0437  0.626  0.0362     1    0.424  -0.184       0
#> 2 cpk_enzyme           0.713   2.08   0.121      1    4.46   25.1         0
#> 3 ejection_fraction    0.00557 0.789  0.0456     1    0.555   0.0414      0
#> 4 platelets            0.0149  1.07   0.0622     1    1.46    6.21        0
#> 5 creatinine           0.588   2.07   0.120      1    4.46   25.8         0
#> 6 sodium              -0.0624  0.735  0.0425     1   -1.05    4.12        0
#> 7 time                 0.117   0.597  0.0345     1    0.128  -1.21        0

# Statistics of numerical variables normalized by Min-Max method
summary(all_var, stand = "minmax")
#> # A tibble: 7 × 8
#>   described_variables   mean    sd se_mean    IQR skewness kurtosis median
#>   <chr>                <dbl> <dbl>   <dbl>  <dbl>    <dbl>    <dbl>  <dbl>
#> 1 age                 0.379  0.216 0.0125  0.345     0.424  -0.184  0.364 
#> 2 cpk_enzyme          0.0713 0.124 0.00716 0.0594    4.46   25.1    0.0290
#> 3 ejection_fraction   0.365  0.179 0.0104  0.227     0.555   0.0414 0.364 
#> 4 platelets           0.289  0.119 0.00686 0.110     1.46    6.21   0.287 
#> 5 creatinine          0.100  0.116 0.00672 0.0562    4.46   25.8    0.0674
#> 6 sodium              0.675  0.126 0.00729 0.171    -1.05    4.12   0.686 
#> 7 time                0.449  0.276 0.0160  0.463     0.128  -1.21   0.395 

# Statistics of numerical variables standardized by Z-score method
summary(all_var, stand = "zscore")
#> # A tibble: 7 × 8
#>   described_variables      mean    sd se_mean   IQR skewness kurtosis   median
#>   <chr>                   <dbl> <dbl>   <dbl> <dbl>    <dbl>    <dbl>    <dbl>
#> 1 age                  2.11e-16  1.00  0.0578 1.60     0.424  -0.184  -0.0697 
#> 2 cpk_enzyme          -2.14e-17  1.00  0.0578 0.480    4.46   25.1    -0.342  
#> 3 ejection_fraction    4.75e-17  1.00  0.0578 1.27     0.555   0.0414 -0.00706
#> 4 platelets           -1.11e-15  1     0.0578 0.930    1.46    6.21   -0.0139 
#> 5 creatinine           4.03e-16  1.00  0.0578 0.483    4.46   25.8    -0.284  
#> 6 sodium              -8.42e-16  1.00  0.0578 1.36    -1.05    4.12    0.0849 
#> 7 time                -6.05e-16  1.00  0.0578 1.67     0.128  -1.21   -0.197  
# }