The fonction combinations of the hier.part package will do the job, I think.
require(hier.part) combos(2)$binary [,1] [,2] [1,] 1 0 [2,] 0 1 [3,] 1 1 combos(3)$binary [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 [4,] 1 1 0 [5,] 1 0 1 [6,] 0 1 1 [7,] 1 1 1
Except that you will need to add a “null” combination. NTN
source share