Hello there,

I have a matrix with some data and I want to split this matrix based on the
values in one column. Is there a quick way of doing this? I have looked at
cut but I am not sure how to exactly use it?
for example:

I would like to split the matrix "a" based on the spending such that the
data is binned groups [0..99],[100..199]...and so on.

a <- data.frame(patient=1:7, charges=c(100,500,200,90,400,500,600),
 age=c(0,3,5,7,10,16,19),  spending=c(10, 60, 110, 200, 250, 400, 450))

Expected  output -
bin[1] <- c(10, 60)
bin[2] <- c(110, 200, 250)
bin[3] <- c(400, 450)

NOTE that the number of data points in each bin is not the same and the
empty bins are removed (since there are no points between [199..299],
bin[3] starts at 400.

Any help would be most appreciated. Thank you in advance.

Diviya

	[[alternative HTML version deleted]]

