Find most common combination in binary data set in R? I have a dataset with 7 variables all binary.

I summed them across rows
var8<- (x1+x2+x3+x4+x5+x6+x7)
which gave me a vector of values 1:7
I then used the table functions to find the frequency of each which yielded:
0   1     2     3     4     5    6    7
82  562  1560  2642  2647  1577  517  94
What I'd like to know is if there's a way I can see the most frequent combinations of variables. for example if x1, x2, and x4, was the most frequent combination. Also, can I essentially see a ranked list of them, such as, the above combination being most frequent, x1,x2, being second most frequent, x2,x4,x7 being third most frequent, etc.? If you need any more info or clarity let me know.
 A: I'll use a toy example:
> X<-cbind(c(1,1,0,0,1,0,1,0,1,0), c(0,0,1,1,0,0,1,1,0,0))
> colnames(X)<-c('x1','x2')
> X
      x1 x2
 [1,]  1  0
 [2,]  1  0
 [3,]  0  1
 [4,]  0  1
 [5,]  1  0
 [6,]  0  0
 [7,]  1  1
 [8,]  0  1
 [9,]  1  0
[10,]  0  0

You may apply paste function to each row of X to obtain values from rows merged to strings:
> Xcollapsed<-apply(X,1,paste,collapse='')
> Xcollapsed
 [1] "10" "10" "01" "01" "10" "00" "11" "01" "10" "00"

Then you can easily tabulate and sort them:
> table(Xcollapsed)
Xcollapsed
00 01 10 11 
 2  3  4  1 

> sort(table(Xcollapsed))
Xcollapsed
11 00 01 10 
 1  2  3  4 

So, here in my example, the most common pattern is 10 which translates to x1 marked with 1 and x2 with 0.
A: I don't know whether any R function is available for this task or not. But I think, this is also done by writing your own function.
So, you have 7 binary features forming vector of length 7. So, total possible vectors in this case are 2^7 = 128. You can generate these vectors by for loop and store each vector in a list. Such as,
vectors = list()      

for i in [0,1]:
     for j in [0,1]:
         ...
            for o in [0,1]:    # 7 for loops
                  vectors.append((i,j,k,l,m,n,o))

So, now vectors contains all possible vectors.
Now, you need to compare each vector with your data and store its frequency.
Frequencies = [0]*128    
index = 0
for vector in vectors:
     for item in yourdataset:
         if vector == item:
              Frequencies[index] += 1  
     index += 1

So, now you have frequencies of all possible vectors. You can make dictionary with key-value pair from vectors and frequecies and then sort that dictionary based on frequencies in decreasing order.
