Skip to content
Prev 221000 / 398500 Next

How to rank matrix data by deciles?

On 2010-05-13 17:50, Phil Spector wrote:
The problem is that quantile() produces multiple values
for the breaks used in cut(). Phil's suggestion modifies
the data. It might be preferable to modify the breaks:

   eps <- .Machine$double.eps  #or use something like 1e-10
   brks <- quantile(vec, (0:10)/10) + eps*(0:10)
   cut(vec, brks, include.lowest=TRUE, labels=FALSE)
   #[1] 10  6  7  5  9  1  3  7  4  2  9  4  1 10  5  8  1

  -Peter Ehlers