# Using the Cut2 Function in R Programming

## Another function, cut2(), in the Hmsic library will help group the observations of your dataset. Here’s how.

I explained in an earlier post how the *cut()* function in R programming worked. Yet more than one version of that function is available. That second one, *cut2()*, is included in the *Hmisc* library. It provides more nuanced features in identifying bins among a vector of data. This post will explain some of the details so you can appreciate the options and be imaginative in how you categorize your data.

The *cut2()* function has vectors, cut points, the minimum number of observations in a group, a number of quartile groups, and some additional parameters.

One difference is the cutpoints for each bin. The “cutpoints” describe the start and end points of the bin groups.

In *cut()* you have a starting point, lower, and end point, upper. They appear as (lower, upper] which indicates the cutpoints for a bin range that excludes the lower number.

In *cut2(),* the bins have inclusive lower endpoints and exclude the upper endpoint. The bins in the data range appear as [lower, upper), with the exception that the last interval is completely inclusive — [lower, upper]. This means *cut2()* will by default ensure that…