Is there a way to calculate the frequency of combinations from a set of binary variables?
a <- c(0,1,0,1,0)
b <- c(1,1,0,1,0)
c <- c(0,1,0,0,0)
> data.frame(a, b, c)
a b c
1 0 1 0
2 1 1 1
3 0 0 0
4 1 1 0
5 0 0 0
In this example, combination a + b is the most common, since obj. 2 and 4 have these. I only want to count combinations with at least 2 variables containing [1]. Is there a way to calculate this ? I would appreciate any thoughts or ideas!
My expected output should be like this:
combinations
1 ab 2
2 ac 1
3 bc 1
4 abc 1