0
data = data.frame(do.call("rbind", list(c(1, 2, 3, 4), c(1, 3, 2, 4),
+ c(1, 2, 3, 4), c(1, 2, 1, 2))))
data
  X1 X2 X3 X4
1  1  2  3  4
2  1  3  2  4
3  1  2  3  4
4  1  2  1  2

For this data.frame, I would like to know how many distinct rows there are. In this case there are 3 distinct rows since rows 1 and 3 are the same. How can I write code to know which sequences are unique and how many times they show up?

I'm hoping to get something along the lines of

sequence    n
1 2 3 4     2
1 3 2 4     1
1 2 1 2     1
zx8754
  • 52,746
  • 12
  • 114
  • 209
Adrian
  • 9,229
  • 24
  • 74
  • 132
  • See [duplicated](https://stat.ethz.ch/R-manual/R-devel/library/base/html/duplicated.html) – zx8754 Sep 15 '15 at 08:04
  • An option that is not yet in the dupe would be `library(dplyr); count_(data, names(data))` (possibly followed by `%>% ungroup`) – talat Sep 15 '15 at 09:27

0 Answers0