[R] Problem in Binning of a data set
Petr PIKAL
petr.pikal at precheza.cz
Thu Jun 19 14:20:08 CEST 2008
Hi
well AFAICS nothing is in contradiction what I recommended so far.
> test<-read.delim("clipboard", sep="")
> head(test)
A R F M
1 man1 1 11 21
2 man2 2 12 22
3 man3 3 13 23
4 man4 4 14 24
5 man5 5 15 25
6 man6 6 16 26
>
> rf<-cut(test$R, c(0,3,6,100))
> ff<-cut(test$F, c(0,13,16,100))
> mf<-cut(test$M, c(0,23,26,100))
> split(test, interaction(rf,ff,mf))
$`(0,3].(0,13].(0,23]`
A R F M
1 man1 1 11 21
2 man2 2 12 22
3 man3 3 13 23
$`(3,6].(0,13].(0,23]`
[1] A R F M
<0 rows> (or 0-length row.names)
$`(6,100].(0,13].(0,23]`
[1] A R F M
<0 rows> (or 0-length row.names)
$`(0,3].(13,16].(0,23]`
[
Regards
Petr
petr.pikal at precheza.cz
724008364, 581252140, 581252257
"sumit gupta" <sumit.iitm at gmail.com> napsal dne 19.06.2008 12:13:27:
>
> Hi..
>
> I am giving a toy example here..
>
> R F M
> man1 1 11 21
> man2 2 12 22
> man3 3 13 23
> man4 4 14 24
> man5 5 15 25
> man6 6 16 26
> man7 7 17 27
> man8 8 18 28
> man9 9 19 29
> man10 10 20 30
> Now I want to split the above data for following intervals
> R1- (1-3) F1(11-13) M1(21-23)
> R2- (4-6) F2(14-16) M1(24-26)
> R3- (7-10) F3(17-20) M1(27-30)
> now I want to create folowing 27 ( 3X3X3) bins
> 1 R1,F1,M1
> 2 R1,F1,M2
> 3 R1,F1,M3
> 4 .
> .
> .
> .
> .
> 9 R1,F3,M3
>
> 10 R2,F1,M1
> 11 R2,F1,M2
> 12 R2,F1,M3
> 13 .
> .
> .
> .
> .
> 18 R2,F3,M3
>
> 19 R3,F1,M1
> 20 R3,F1,M2
> 21 R3,F1,M3
> 22 .
> .
> .
> .
> .
> 27 R3,F3,M3
> and save each bin as a separate data set.
>
> Thanx in advance
> Sumit
>
>
> On 6/19/08, Petr PIKAL <petr.pikal at precheza.cz> wrote:
> 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
>
>
>
> --
> Sumit Kumar Gupta
> 4thYear ,Biotechnology
> IIT Madras
More information about the R-help
mailing list