Thank you I works as I need. > aggregate(tmp[,5],list(tmp[,2],tmp[,1]),function(x) sum(table(x))) Group.1 Group.2 x 1 0.0 D 100 2 0.2 D 100 3 0.4 D 100 4 0.6 D 72 5 0.8 D 9
2011/10/22 Weidong Gu <anopheles...@gmail.com> > Thanks for providing the example data, try this > > aggregate(si[,7],list(si[,2],si[,1]),function(x) sum(table(x))) > > Weidong > > On Sat, Oct 22, 2011 at 9:28 AM, Adel ESSAFI <adel.s...@imag.fr> wrote: > > NO > >> aggregate(si[,7],list(si[,2],si[,1]),mean) > > Group.1 Group.2 x > > 1 0.0 D 212.5015448 > > 2 0.2 D 200.5271137 > > 3 0.4 D 191.5387529 > > 4 0.6 D 131.5856218 > > 5 0.8 D 16.4515798 > > 6 1.0 D 0.9698699 > > 7 0.0 F 211.6176036 > > 8 0.2 F 199.5358336 > > 9 0.4 F 179.1472057 > > 10 0.6 F 70.3376311 > > 11 0.8 F 25.0939253 > > 12 1.0 F 0.9759778 > > 13 0.0 I 199.1829674 > > 14 0.2 I 188.8703456 > > 15 0.4 I 147.5194562 > > 16 0.6 I 18.1743204 > > 17 0.8 I 0.9563789 > > 18 1.0 I 0.9531993 > > 19 0.0 L 95.1813009 > > 20 0.2 L 95.1813009 > > 21 0.4 L 92.3533476 > > 22 0.6 L 47.1235041 > > 23 0.8 L 9.4129464 > > 24 1.0 L 0.9336508 > > 25 0.0 S 95.1813009 > > 26 0.2 S 91.4119070 > > 27 0.4 S 81.9875960 > > 28 0.6 S 11.3183831 > > 29 0.8 S 1.8843307 > > 30 1.0 S 0.9310779 > > > > for exemple, for the last line, I want aggregate to show me the number of > > lines with col1=1 and col2=S in stead of the mean. > > > > Regards > > > > > > > > 2011/10/22 Weidong Gu <anopheles...@gmail.com> > >> > >> Is this waht you want? > >> > >> sci[,5][sci[,2]==0 & sci[,1]==L] > >> > >> Weidong > >> > >> On Sat, Oct 22, 2011 at 8:19 AM, Adel ESSAFI <adeless...@gmail.com> > wrote: > >> > Hi, > >> > It is not what I want, but, thx anyway. > >> > Regards > >> > > >> > > >> > 2011/10/22 Weidong Gu <anopheles...@gmail.com> > >> >> > >> >> try this > >> >> > >> >> table(sci[,2]=0,sci[,1]=L) > >> >> > >> >> Weidong Gu > >> >> > >> >> On Sat, Oct 22, 2011 at 7:51 AM, Adel ESSAFI <adel.s...@imag.fr> > wrote: > >> >> > Hello, > >> >> > is there any help please. > >> >> > Regards > >> >> > > >> >> > > >> >> > 2011/10/21 Adel ESSAFI <adeless...@gmail.com> > >> >> > > >> >> >> Hello > >> >> >> I am discovering R and I find it is really very powerful. > >> >> >> > >> >> >> However, I find some newbie difficulties. > >> >> >> > >> >> >> Here, I have a data frame with manu values that I want to > calculate > >> >> >> the > >> >> >> frequency (the nomber of line) of the some criteria. > >> >> >> For exemple here, I want it to print the number of occurence > where > >> >> >> sci[,2]=0 and sci[,1]=L. In my exemple, he is printing the number > of > >> >> >> the > >> >> >> line in the result data frame. > >> >> >> however, I have at least 90 line with sci[,2]=0 and sci[,1]=L. > >> >> >> Thank you in advance for any input. > >> >> >> > >> >> >> > >> >> >> > aggregate(sci[,5],list(sci[,2],sci[,1]),frequency) > >> >> >> Group.1 Group.2 x > >> >> >> 1 0.0 L 1 > >> >> >> 2 0.2 L 1 > >> >> >> > >> >> >> > >> >> >> -- > >> >> >> PhD candidate in Computer Science > >> >> >> Address > >> >> >> 3 avenue lamine, cité ezzahra, Sousse 4000 > >> >> >> Tunisia > >> >> >> tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) > >> >> >> fax: +216 71 391 166 > >> >> >> > >> >> > > >> >> > > >> >> > > >> >> > -- > >> >> > *PhD candidate in Computer Science > >> >> > Address > >> >> > 3 avenue lamine, cité ezzahra, Sousse 4000 > >> >> > Tunisia > >> >> > tel: +216 97 246 706 > >> >> > fax: +216 71 391 166* > >> >> > > >> >> > [[alternative HTML version deleted]] > >> >> > > >> >> > > >> >> > ______________________________________________ > >> >> > R-help@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. > >> >> > > >> >> > > >> >> > >> >> ______________________________________________ > >> >> R-help@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. > >> > > >> > > >> > > >> > -- > >> > PhD candidate in Computer Science > >> > Address > >> > 3 avenue lamine, cité ezzahra, Sousse 4000 > >> > Tunisia > >> > tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) > >> > fax: +216 71 391 166 > >> > > > > > > > > > -- > > PhD candidate in Computer Science > > Address > > 3 avenue lamine, cité ezzahra, Sousse 4000 > > Tunisia > > tel: +216 97 246 706 > > fax: +216 71 391 166 > > > > -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]]
______________________________________________ R-help@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.