Description Usage Arguments Value Examples
Function which bins numeric vector into bins of equal weight (or a smooth function on weight).
1 2 3 4 5 6 7 8 9 | prep_num_bin(
var_to_band,
n_bins = 10,
weight = NULL,
method = "even_weight",
use_labels = FALSE,
mean = 0.5,
sd = 0.3
)
|
var_to_band |
Vector[numeric] - vector of values to be binned |
n_bins |
numeric - Number of bins to split exposure into |
weight |
numeric - vector weight for observations |
method |
string - One of |
use_labels |
logical - should the bins be numbered or human readable labelled |
mean |
numeric - Only used when |
sd |
numeric - Only used when |
a list with the following named entried:
bins: Either a numeric vector or a factor (depending on use_labels
) which gives the bin. The vector is of length length(var_to_band)
and has n_bins
unique values
labels: Human readable labels of where binning has occored
vector with values 1 to n_bins
indicating bin of var_to_band. (1 is low var_to_band
and n_bins
is high var_to_band
)
1 2 3 | prep_num_bin(var_to_band=1:20, n_bins=5)
prep_num_bin(var_to_band=1:20, n_bins=5, method="gaussian_weight")
prep_num_bin(var_to_band=1:20, n_bins=5, method="gaussian_weight", use_labels=TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.