I have a dataset which has two columns matchid
and roundnumber
which looks like:
matchid roundnumber
1522380841 1
1522380841 2
1522380841 1
1522380841 3
1522380841 2
1522380841 1
1522380841 1
1522380842 2
1522380842 2
1522380842 3
1522380842 1
1522380842 4
1522380842 1
I cannot figure out how to count the total number of times a single matchid
and roundnumber
should exist.
For this example, the output should be:
count (matchid)
2
I think it needs a unique
constraint perhaps? For each matchid
, there can be duplicate values of roundnumber
, but I need to count them just once. I just need to find out how many unique matchid
exists.
I tried using dplyr:
library(dplyr)
count(r6,var=r6$matchid,r6$roundnumber)
but I don't think it works correctly.