set_bins: given a set of bin ranges, assign each value to a bin

Description Usage Arguments Details

View source: R/set_bins.R

Description

given a set of bin ranges, assign each value to a bin

Usage

1
2
3
4
5
6
7
8
9
set_bins(
  x,
  breaks = stats::quantile(x, na.rm = T),
  lower_bound = -Inf,
  upper_bound = Inf,
  quiet = TRUE,
  between = NULL,
  inclusive = TRUE
)

Arguments

x

numeric vector to assign bins

breaks

breaks for each bin, defaults to quantiles

lower_bound

set a lower bound for the first bin, defaults to -Inf

upper_bound

set an upper bound for the last bind, defaults to Inf

quiet

whether to give additonal information regarding bins and assigned range for each

between

defaults to NULL, a special case of setting all inside the specified range

inclusive

include max value of largest user defined bin even though lower bins are non-inclusive

Details

Given a set of quantiles/bins/etc established from a separate dataset, it can be useful to assign the same bins to new or simulated data for comparisons or to do additional analysis such as assign dropouts etc. This function can be used to take the breakpoints to establish bins quickly and easily

If there is concern over data being outside the range of the assigned breaks, one can assign -Inf to lower and/or Inf to upper to make sure all values will be assigned to a bin

To use the between functionality, you must specify the range you wish to bin between, and those values will be assigned to bin 1, with all values below as 0 and all values above as 2. See the examples for more details


PKPDmisc documentation built on April 14, 2020, 5:49 p.m.