i didn't test, but i think you want something like:
table(apply(x, 1, paste, collapse=","))
where "x" is your matrix...
b
On Dec 23, 2007, at 5:01 AM, Jim Lemon wrote:
Louis Martin wrote:
Hi,
I have a matrix of duplicate rows. How to output a list the unique
rows with their count? I have
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.
Hi Louis,
If I am understanding your question correctly, here is one way:
suppose your matrix is M of dimension n x k.
D <- data.frame(M) # convert to data frame
ones <- rep(1, n) # a column of 1s
Now you can count the number of repeats of each unique row.
aggregate( ones, by = as.list(D), F
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.
Thanks
Louis
-
[[alternative HTML version de
4 matches
Mail list logo