Suppose I have the following vector:
V<-c(-1,-1,1,1,1,-1,-1,1)
And I want to know the number of different pairs in the following categories:
(1,1), (-1,1), (1, -1) and (-1, -1)
In my example, there is exactly one pair of each.
I am trying to solve this problem with the function splitand setkey, but I can not categorize.
source
share