This is best thought of in terms of a matrix-like object of binary values in which each row of the matrix represents a number in base 2. For n columns, there are n^2 distinct rows. For n = 3, that is 8 and for n = 8, 256.
In the general case, a problem in R should be thought of as finding a solution to f(x) = y. f, x, \&\space y are all objects, and those objects, including the function, f may be composed of other objects.
Considering dataz as a matrix, we have x. For y we seek a data frame containing two columns, call them set and n, where set is the number base2 that corresponds to the presence or absence of some attribute in x and N is the number of occurrences.
For example, in the dataz example, a row of x evaluating to 4, (binary 1\space0\space0) indicates the value of 1 for a1 and values of 0 for a2 and a3. For the case in which there are a1 ... a8, a row evaluating to 256 (binary 1\space0\space0\space0\space0\space0\space0\space0\space0) is comparable.
To obtain the tabulation, dplyr provides summarize() and count()
suppressPackageStartupMessages(library(dplyr))
a1=c(1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
a2=c(1,0,0,1,1,1,1,0,0,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
a3=c(1,0,0,1,0,0,0,1,1,0,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
a_total=c(3,0,1,2,1,1,1,1,1,1,1,1,1,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
dataz=data.frame(a1,a2,a3,a_total)
dataz %>% select(-a_total) %>%
group_by(a1,a2,a3) %>%
count()
#> # A tibble: 6 x 4
#> # Groups: a1, a2, a3 [6]
#> a1 a2 a3 n
#> <dbl> <dbl> <dbl> <int>
#> 1 0 0 0 20
#> 2 0 0 1 3
#> 3 0 1 0 5
#> 4 0 1 1 3
#> 5 1 0 0 2
#> 6 1 1 1 2
Created on 2020-09-07 by the reprex package (v0.3.0)
Other transformations depend on the details of representation of the results.