Learn R Programming

dlookr (version 0.3.9)

summary.bins: Summarizing Binned Variable

Description

summary method for class "bins" and "optimal_bins".

Usage

# S3 method for bins
summary(object, ...)

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

Arguments

object

an object of class "bins" and "optimal_bins", usually, a result of a call to binning().

...

further arguments passed to or from other methods.

x

an object of class "bins" and "optimal_bins", usually, a result of a call to binning().

Value

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 : levles of factor.

  • freq : frequency of levels.

  • rate : ratio of levels in total observations. it is not percentage.

Details

print.bins() tries to be smart about formatting the frequency of bins, binned type, number of bins. summary.bins tries to be smart about formatting the levles, frequency of levels(bins), the ratio of levels in total observations. And this information is data.frame object.

See vignette("transformation") for an introduction to these concepts.

See Also

binning

Examples

Run this code
# NOT RUN {
# Generate data for the example
carseats <- ISLR::Carseats
carseats[sample(seq(NROW(carseats)), 20), "Income"] <- NA
carseats[sample(seq(NROW(carseats)), 5), "Urban"] <- NA

# Binning the carat variable. default type argument is "quantile"
bin <- binning(carseats$Income)

# Print bins class object
bin

# Summarise bins class object
summary(bin)
# }

Run the code above in your browser using DataLab