Create Category by Cutting Continuous Data

DESCRIPTION:

Creates a category object by dividing continuous data into intervals. Either specific cut points or the number of equal width intervals can be specified.

USAGE:

cut(x, ...) 
cut.default(x, breaks, labels=<<see below>>, include.lowest=F,  
            factor.result=F, left.include=F) 

REQUIRED ARGUMENTS:

x
data vector or bdVector. Missing values ( NAs) are allowed.
breaks
either a vector of breakpoints, or the number of equal-width intervals into which the data in x should be cut. If a vector of breakpoints is given, the category will have length(breaks)-1 groups, corresponding to data in the intervals between successive values in breaks ( breaks must be sorted).

OPTIONAL ARGUMENTS:

labels
character vector of labels for the intervals. The default is to encode the breakpoints to make up interval names, in the form "lower.limit+ thru upper.limit", or "lower.limit thru upper.limit-" if left.include is TRUE.
include.lowest
If TRUE, then make the lowest bin include its lower endpoint, otherwise (the default) make the lowest bin act like the others, which include the upper endpoint but not the lower. (If left.include is TRUE, then include.lowest should really be called include.highest, because it makes the highest bin include its higher endpoint instead of having the default behavior of having each bin include the lower endpoint but not the higher.)
factor.result
if TRUE, then call as.factor on the result before returning.
left.include
if TRUE, then make each bin include its left (lower) endpoint instead of having each bin include its right (upper) endpoint. Also reverses the meaning of include.lowest. The default is TRUE for timeDate related classes such as positionsCalendar and timeSpan.

VALUE:

a vector or bdVector as long as x telling which group each point in x belongs to, along with an attribute, levels, which is a vector of character names for each group.

DETAILS:

If left.include is FALSE (the default), then data less than or equal to the first breakpoint or greater than the last breakpoint are returned as NA. Each group consists of data greater than one breakpoint and less than or equal to the next breakpoint. (However, if include.lowest is TRUE, the bottommost group also includes data equal to the lowest breakpoint.) If left.include is TRUE, then data less than the first breakpoint or greater or equal to the last breakpoint are returned as NA. Each group consists of data greater or equal to one breakpoint and less than the next breakpoint. (However, if include.lowest is TRUE, the uppermost group also includes data equal to the highest breakpoint.) In either case, missing values in x create missing values in the result. The cut function is generic.

SEE ALSO:

, , , .

EXAMPLES:

x <- 1:10 
cut(x, 3)   # cut into 3 groups 
cut(x, c(0,5,11))  # cut based on given breakpoints 
cut(x, pretty(x))   # approx 5 "pretty" intervals 
cut(x, c(1,5,10), left.include=T, inc=T) # cut using left intervals