bin: Divides x into bins specified by breaks or a bin size

binR Documentation

Divides x into bins specified by breaks or a bin size

Description

Divides x into bins specified by breaks or a bin size

Usage

bin(x, breaks, blabels = names(breaks), breaklast = NULL)

Arguments

x

numeric vector to be binned

breaks

either a numeric vector of two or more cut points, or a single number giving the size of the bins in which case x is divided in bins of size breaks. NB: if cut points are specified, note that the cut point value is not included in the bin (ie: include.lowest = FALSE) Therefore the very first cut point must be less than min(x). Subsequent cut points are the closed right bound, and the final cut point should be max(x), eg: breaks of c(0, 34, 35, 36, 37, 44) will cut into the following bins (0,34] (34,35] (35,36] (36,37] (37,44]

blabels

labels for the levels of the resulting category. If NULL, labels are constructed using "(a,b]" interval notation. If specified, NAs are removed first. If breaks is specified, the the first cut point must be less than min(x) and its name (ie: the first value in blabels) should be NA. If unspecified, names(breaks) is used.

breaklast

if breaks is a bin size and breaklast is specified then this is the position of the last break

Value

the values of x factored into bins


kcha193/simarioV2 documentation built on April 8, 2024, 4:51 p.m.