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