This question already has an answer here:
- Counting existing permutations in R 2 answers
If I have this data:
One <- c(rep("X",4),rep("Y",3),rep("Z",2))
Two <- c(rep("A",2),rep("B",6),rep("C",1))
df <- data.frame(One,Two)
One Two
1 X A
2 X A
3 X B
4 X B
5 Y B
6 Y B
7 Y B
8 Z B
9 Z C
I want to find the frequency of unique pairs (one,two). I know if I wanted to find the frequency of different elements in column One
I would do table(df$one)
. How about the frequency of unique pairs?