quantileBins: Put values of vector in bins based on quantiles.

Description Usage Arguments Value Examples

View source: R/prepare.R

Description

Put values of vector in bins based on quantiles.

Usage

1
2
3
quantileBins(x, probs = c(0, 0.25, 0.5, 0.75, 1),
  include.lowest = TRUE, as.factor = FALSE, values.as.names = FALSE,
  ...)

Arguments

x

[numeric] Vector you want to bin.

probs

[numeric] Default is seq(0, 1, .25) (i.e. quartiles).

include.lowest

[logical(1)] Include element with lowest value. Who would not want that (except the authors of the base cut function)?

as.factor

[logical(1)] If TRUE returns a factor with quantile boundaries as level labels. Level labels can be changed via the labels argument.

values.as.names

[logical(1)] Return named vector with values of the input so that you can see how bin numbers correspond to values of x.

...

further arguments passed down to the base functions quantile() and cut()

Value

integer(length(x)) or factor

Examples

1
2
3
4
5
6
7
8
9
quantileBins(1:20, values.as.names = TRUE)

n = 200
x = runif(n, min = 0, max = 1)
x1 = x + rnorm(n, 0, 0.05)
x2 = x + rnorm(n, 0, 0.05)
y = x1 + x2^2 + rnorm(n, 0, 0.1)
plot(x1, x2, cex = quantileBins(y, probs = seq(0,1,.1))/5,
  col = quantileBins(y))

BodoBurger/bodomisc documentation built on May 27, 2020, 5:12 p.m.