[R] Problem in Binning of a data set

Petr PIKAL petr.pikal at precheza.cz
Thu Jun 19 10:03:39 CEST 2008


Hi

"sumit gupta" <sumit.iitm at gmail.com> napsal dne 18.06.2008 14:24:28:

> the range of data in all three columns is different. so obviously the 
cut 
> points are different.
> What I want to do is to create a 3D matrix
> 
> Lets say I have the following data
> 
> A              B              C
> 500           5               4000
> 563           4               6540
> 563           4               3456
> 587           2               8000
> .               .                 .
> .               .                 .
> Now I will divide each and every colums in 3 bins 
A1,A2,A3,B1,B2,B3,C1,C2,C3
> 
> Now I want a matrix like 
> 
> for 
> C1
> 
>                 A1       A2       A3
>  B1           a         b          c
>  B2           d          e          f
>  B3           g         h           i
> 
> and create a separate table for each bin( a,b,c,d,e,f,g,h,i) that is 
what all 
> elements are there in each bin a ,b, c, and so on..
> I hope this clarify the problem.

Not too much. What do you mean by bins? Is it some range of values from 
respective column? E.g. for A column the A1 bin is from 0 to 570? Then you 
can use my suggestion to split your whole data to list according to 
created factor.

And of course you can do it for B and C values too, e.g. with interaction.

split(data, interaction(A.bins, B.bins, C.bins))

shall give you a list of data values which are located in respective bins. 
If you are not satisfied with my answer, please do as posting guide 
suggests and provide some toy example which can be reproduced.

Regards
Petr

> 
> Thanx 
> Regards,
> Sumit
> 

> On 6/18/08, Petr PIKAL <petr.pikal at precheza.cz> wrote: 
> Hi
> 
> Well. I am a bit lost in your bins. If I understand correctly you shall
> have some factor with bin values
> 
> bin.f <- cut(some data, levels)
> 
> then you can split your data according to values of bin.f
> 
> split(complete data, bin.f)
> 
> If this does not solve your problem just throw it to some other bin :-)
> 
> Regards
> Petr
> 
> r-help-bounces at r-project.org napsal dne 18.06.2008 08:04:50:
> 
> > Hello,
> >
> > I am having problem with binning the data. I have a 50X3 matrix and I
> binned
> > the data for all the 3 columns. Using table command I got the total 
no.
> of
> > elements in a particular bin.
> > Could you please tell me how to see that what all elements are there 
in
> a
> > particular bin and then create a different matrix for each bin?
> >
> > Thanks.
> >
> > Regards,
> > Sumit
> >
> >    [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

> 
> 
> 
> -- 
> Sumit Kumar Gupta
> 4thYear ,Biotechnology
> IIT Madras



More information about the R-help mailing list