[R] Rank samples by breaks in hist and assign result as factor

Frostygoat frostygoat at gmail.com
Wed Dec 7 01:25:29 CET 2011

Hi R users,

My goal is to rank my samples according to how they fall out in a
histogram with 10 bins to produce a ranking for each sample according
to where it falls on the histogram, with a "1" to represent one tail
of the hist, a "10" to represent the other tail, and a "5" for the
median/mean. I have a number of different data sets to do this with
and in all cases I need this ranking between1-10 regardless of the
number of samples in each set.



[1] -2.0 -1.5 -1.0 -0.5  0.0  0.5  1.0  1.5  2.0

So, I want to add a factor to x where if x is less than -2.0, then new
factor="1"; if x is greater than -2.0 but x is less than -1.5, then
new factor="2", etc.

rank doesn't seem to help

Any tips?

Thanks much.

More information about the R-help mailing list