calculate_decile_table: Calculate a decile breakdown

Description Usage Arguments Examples

View source: R/calculate.R

Description

This function calculates a decile table for any combination of numerical and categorical variables.

Usage

1
2
calculate_decile_table(df, binning, grouping, top_level = "1",
  n_bins = 10, format = FALSE, ...)

Arguments

df

A data frame.

binning

Variable for which binning should be applied.

grouping

A two-level (binary) variable to calculate the ratio in each bin.

top_level

Top level of the grouping variable. Defaults to "1".

n_bins

Provide a number of bins. Defaults to 10.

format

Should table printing be formatted with kable? Defaults to FALSE

...

Additional grouping columns to calculate deciles

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(tidyverse)

diamonds_filter <- diamonds %>% filter(cut %in% c("Ideal", "Premium"))

diamonds_filter %>%
  calculate_decile_table(price, cut, "Ideal")

diamonds_filter %>%
  calculate_decile_table(binning = price,
                         grouping = cut,
                         top_level = "Ideal",
                         n_bins = 10,
                         format = FALSE,
                         color)

konradsemsch/ggrapid documentation built on Nov. 4, 2019, 3:56 p.m.