[R] Help with Hmisc, cut2, split and quantile

Guy Green guygreen at netvigator.com
Mon Mar 8 16:47:57 CET 2010


Hello,
I have a set of data with two columns: "Target" and "Actual".  A 
http://n4.nabble.com/file/n1584647/Sample_table.txt Sample_table.txt  is
attached but the data looks like this:

Actual	Target
-0.125	0.016124906
0.135		0.120799865
...		...
...		...

I want to be able to break the data into tables based on quantiles in the
"Target" column.  I can see (using cut2, and also quantile) how to get the
barrier points between the different quantiles, and I can see how I would
achieve this if I was just looking to split up a vector.  However I am
trying to break up the whole table based on those quantiles, not just the
vector.

The following code shows me the ranges for the deciles of the "Target" data:
library(Hmisc)
read_data=read.table("C:/Sample table.txt", head = T)
table(cut2(Read_data$Target,g=10))

However I would like to be able to break the table into ten separate tables,
each with both "Actual" and "Target" data, based on the "Target" data
deciles:

top_decile = ...(top decile of "read_data", based on Target data)
next_decile = ...and so on...
bottom_decile = ...

That way I could manipulate the deciles, graph them separately (and
together) and so on, just as easily as I can the whole table.  I'm sure this
must be simple, but I can't see the way forward.  I have also looked at
split() and quantile() but have not been able to get them to achieve what I
am after.  Can anybody see a simple way foward on this?

Thanks,
Guy
-- 
View this message in context: http://n4.nabble.com/Help-with-Hmisc-cut2-split-and-quantile-tp1584647p1584647.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list