1 2 3 4 5 6 7 8 9 10 |
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 ( |
bintrans |
(character or numeric) transformation of |
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. |
input data.table with four new columns:
bin - bin number (1 being the lowest value bin)
bin_lmin - bin lower limit
bin_lmax - bin higher limit
bin_lformat - formatted character of bin limits
(format: round(bin_lmin, ndigits) - round(bin_lmax, ndigits))
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:
'manual' - bin continuous data manually. binarg
sets the inner bin limits,
such that the final table will have length(binarg) + 1
bins. The lower end of the
first bin is automatically set to be the minimum value in binvar
and the upper end of
the last bin is set to be the maximum value in binvar
'equal_length' - Bin continuous data such that each bin has the same binvar
interval length.
If bintrans
is not NULL
, then interval length is computed on transformed scale.
binarg
(automatically rounded to the nearest integer) sets the number of bins.
'equal_freq' - Bin continuous data such that each bin has the same number of records.
binarg
(automatically rounded to the nearest integer) sets the number of bins.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.