So try this : aggregate(rep(1, nrow(x)), as.data.frame(x), sum)
On Fri, Sep 17, 2010 at 11:54 AM, Alaios <ala...@yahoo.com> wrote: > My bad :( > unfortunately does not work correct. > > This is some of the output of the table > .............. > [494,] 50 27 > [495,] 50 27 > [496,] 50 27 > [497,] 50 28 > [498,] 50 28 > [499,] 50 28 > [500,] 50 28 > [501,] 51 28 > [502,] 51 28 > [503,] 51 28 > [504,] 51 28 > [505,] 51 28 > [506,] 51 28 > [507,] 51 28 > [508,] 51 28 > [509,] 51 28 > [510,] 51 28 > [511,] 52 28 > [512,] 52 28 > [513,] 52 28 > [514,] 52 28 > [515,] 52 28 > [516,] 52 29 > [517,] 52 29 > [518,] 52 29 > ............ > > > I need the following results > 50 27: 3 > 50 28: 4 > 51 28: 10 > 52 28: 5 > 52 29: 3 > > So far nothing worked. > Best Regards > Alex > > > > ------------------------------ > *From:* Henrique Dallazuanna <www...@gmail.com> > *To:* Alaios <ala...@yahoo.com> > > *Cc:* Rhelp <r-help@r-project.org> > *Sent:* Fri, September 17, 2010 3:09:36 PM > > *Subject:* Re: [R] count frequency > > Try this: > > aggregate(rep(1, nrow(x)), x, sum) > > On Fri, Sep 17, 2010 at 9:19 AM, Alaios <ala...@yahoo.com> wrote: > >> Hello everyone, >> please consider the following lines of a matrix >> >> >> [574,] 59 32 >> [575,] 59 32 >> [576,] 59 32 >> [577,] 59 32 >> [578,] 59 32 >> [579,] 59 32 >> [580,] 59 32 >> [581,] 60 32 >> [582,] 60 33 >> [583,] 60 33 >> [584,] 60 33 >> [585,] 60 33 >> [586,] 60 33 >> [587,] 60 33 >> [588,] 60 33 >> [589,] 60 33 >> [590,] 60 33 >> [591,] 61 33 >> [592,] 61 33 >> [593,] 61 33 >> [594,] 61 33 >> [595,] 61 33 >> [596,] 61 33 >> [597,] 61 33 >> [598,] 61 33 >> [599,] 61 33 >> [600,] 61 33 >> [601,] 62 34 >> >> Is it possible somehow to count the similarities between the first and >> second >> column and put them on a third column like this? >> >> 59 32 3 >> 60 33 5 >> 62 34 1 >> >> where (3,5,1 are the frequencies for (59,32), (60,33) and (62,34) >> >> Best Regards >> Alex >> >> >> >> >> [[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. >> > > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.