Learn R Programming

rgr (version 1.1.15)

cutter: Function to Identify in Which Interval a Value Falls

Description

Function to identify in which interval of a set of cut points, cuts, a value x falls within or beyond. The number of intervals is equal to the number of cut points plus 1. Values of x have to exceed the value of the cut point to be allocated to the higher interval.

Usage

cutter(x, cuts)

Arguments

x

name of the vector to be processed.

cuts

the vector of cut points.

Value

xi

a vector of the same length as x containing an integer between 1 and the number of cut points plus 1 indicating in which interval each value of x fell. Values <cut[1] have xi set to 1, and values >cut[highest] have xi set to the number of cut points plus 1.

Examples

Run this code
# NOT RUN {
## Make test data available
data(kola.c)
attach(kola.c)

## Cut the data into quartiles
xi <- cutter(Cu, quantile(Cu, probs = c(0.25, 0.5, 0.75)))

## Detach test data
detach(kola.c)
# }

Run the code above in your browser using DataLab