summary method for "bins" and "optimal_bins".
an object of "bins" and "optimal_bins", usually, a result of a call to binning().
further arguments passed to or from other methods.
an object of class "bins" and "optimal_bins", usually, a result of a call to binning().
The function summary.bins() computes and returns a data.frame of summary statistics of the binned given in object. Variables of data frame is as follows.
levels : levels of factor.
freq : frequency of levels.
rate : relative frequency of levels. it is not percentage.
print.bins() prints the information of "bins" and "optimal_bins" objects nicely. This includes frequency of bins, binned type, and number of bins. summary.bins() returns data.frame including frequency and relative frequency for each levels(bins).
See vignette("transformation") for an introduction to these concepts.
# Generate data for the example
heartfailure2 <- heartfailure
heartfailure2[sample(seq(NROW(heartfailure2)), 20), "platelets"] <- NA
# Binning the platelets variable. default type argument is "quantile"
bin <- binning(heartfailure2$platelets)
# Print bins class object
bin
#> binned type: quantile
#> number of bins: 10
#> x
#> [25100,156866.7] (156866.7,200200] (200200,222133.3] (222133.3,237266.7]
#> 28 28 28 28
#> (237266.7,263358] (263358,265933.3] (265933.3,283866.7] (283866.7,323400]
#> 27 28 28 28
#> (323400,380666.7] (380666.7,850000] <NA>
#> 28 28 20
# Summarize bins class object
summary(bin)
#> levels freq rate
#> 1 [25100,156866.7] 28 0.09364548
#> 2 (156866.7,200200] 28 0.09364548
#> 3 (200200,222133.3] 28 0.09364548
#> 4 (222133.3,237266.7] 28 0.09364548
#> 5 (237266.7,263358] 27 0.09030100
#> 6 (263358,265933.3] 28 0.09364548
#> 7 (265933.3,283866.7] 28 0.09364548
#> 8 (283866.7,323400] 28 0.09364548
#> 9 (323400,380666.7] 28 0.09364548
#> 10 (380666.7,850000] 28 0.09364548
#> 11 <NA> 20 0.06688963