[R] Binning question (binning rows of a data.frame according to a variable)

Dan Bolser dmb at mrc-dunn.cam.ac.uk
Fri Mar 17 17:01:58 CET 2006


Hi,

I have tuples of data in rows of a data.frame, each column is a variable 
for the 'items' (one per row).

One of the variables is the 'size' of the item (row).

I would like to cut my data.frame into groups such that each group has 
the same *total size*. So, assuming that we order by size, some groups 
should have several small items while other groups have a few large 
items. All the groups should have approximately the same total size.

I have tried various combinations of cut, quantile, and ecdf, and I just 
can't work out how to do this!

Any help is greatly appreciated!

All the best,
Dan.




More information about the R-help mailing list