Re: [R] number of count of each unique row

From: Jim Lemon <>
Date: Sun, 23 Dec 2007 21:01:31 +1100

Louis Martin wrote:
> Hi,
> I have a matrix of duplicate rows. How to output a list the unique rows with their count? I have used "unique" to have the unique rows, but can't produce the occurences of each unique row.
Hi Louis,
If you want the unique rows returned, this might do the job.

unique.rows<-function(x) {
  for(i in 1:(nrows-1)) {
   for(j in (i+1):nrows) {
    if(![j])) if(all(x[i,]==x[j,])) urows[j]<-NA    }

Jim mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 23 Dec 2007 - 10:05:27 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 Sun 23 Dec 2007 - 11:30:20 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.