cut(x, breaks=2, labels=c("low","hi") )

cut divides the range of x into intervals and codes the values in x according to which interval they fall. The leftmost interval corresponds to level one, the next leftmost to level two and so on.

Usage
x = rnorm(100)

Split into categories with equal range of (not equal count of contents!*)

hist(cut(x, breaks=2), plot=F)

  • nb: use cut2 to break into equal content bins. Use quantile to find percentiles

Choose labels

cut(x, breaks=2, labels=c("low","hi") )

cut(x, breaks=2, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ordered_result = FALSE)

cut(x, breaks=2, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ordered_result = FALSE)

cut(x, breaks=2, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ordered_result = FALSE)

breaks
either a numeric vector of two or more cut points or a single number (greater than or equal to 2) giving the number of intervals into which x is to be cut.

labels
labels for the levels of the resulting category. By default, labels are constructed using "(a,b]" interval notation. If labels = FALSE, simple integer codes are returned instead of a factor.

cut(x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ordered_result = FALSE)