bin_dt: Bin data.table

Usage Arguments Value

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
bin_dt(
  in_dt,
  binvar,
  binfunc,
  binarg,
  bintrans = NULL,
  ndigits = 2,
  na.rm = FALSE,
  valuevar = NULL
)

Arguments

in_dt

data.table to bin.

binvar

(character) column that will be used to define bins.

binfunc

(character) binning approach. One of 'manual', 'equal_length', 'equal_freq'.

binarg

(numeric) binning argument, depends on binning approach (binfunc).

bintrans

(character or numeric) transformation of binvar, default is NULL.

ndigits

(integer) number of decimals to keep for displaying formatted bin limits

na.rm

(logical) whether to include NAs.

valuevar

(character) if na.rm = FALSE, column to use to detect NAs and remove records.

Value

input data.table with four new columns:

Bins a data.table over a numeric column. inspired from rbin package. Differences include that it concentrates all binning approaches within a single function and works on a data.table.

binfunc:

bintrans: can either be 'log' (for natural log) or a numeric exponent to transform according to x^bintrans. for examples, see applications in bin_misclass, eval_watergap, tabulate_globalsummary, formathistab, compare_us


NaiaraLopezRojo/globalIRmap documentation built on Dec. 17, 2021, 5:19 a.m.