coarsen function

Coarsen a vector into a factor with a lower number of levels