A while back I asked a question about how to return the total unique combinations and frequency of customers by brand. This week, I am trying to find the number of customers based on permutations of brands. The permutations cannot repeat themselves.
Here is my sample data:
data_test <- data.frame(CustomerID = c('AA',
'AA',
'AA',
'AA',
'BB',
'BB',
'CC'),
Brand = c('A',
'B',
'C',
'D',
'C',
'D',
'C'))
And here is what I am trying to get:
# A tibble: 4 x 2
Combinations n
<chr> <int>
1 A 1
2 A-B 1
3 A-B-C 1
4 A-B-C-D 1
5 B 1
6 B-C 1
7 B-C-D 1
8 C 3
9 C-D 2
10 D 2
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…