[R] counting identical data in a column

From: joseph <jdsandjd_at_yahoo.com>
Date: Mon, 4 Feb 2008 11:33:18 -0800 (PST)


Hi Peter
I have the following data frame with chromosome name, start and end positions:

   chrN start end
1 chr1 11122333 11122633
2 chr1 11122333 11122633
3 chr3 11122333 11122633
8 chr3 111273334 111273634
7 chr2 12122334 12122634
4 chr1 21122377 21122677
5 chr2 33122355 33122655
6 chr2 33122355 33122655
I would like to count the positions that have the same start and add a new column with the count number; the new data frame should look like this:

  chrN     
 start         end              count
1 chr1  11122333  11122633       3
2 chr1  11122333  11122633       3
3 chr3  11122333  11122633       3
8 chr3 111273334 111273634     1
7 chr2  12122334  12122634       1
4 chr1  21122377  21122677       1
5 chr2  33122355  33122655       2
6 chr2  33122355  33122655       2

Can you please show me how to achieve this? Thanks
Joseph


Be a better friend, newshound, and

        [[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. Received on Mon 04 Feb 2008 - 19:35:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 04 Feb 2008 - 20:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive