Q:

Finding unique columns

Please help. I have a data frame like the following:
df <- data.frame("G"=c(1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7), 
                  "C"=c(1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0),
                "SKU"=c("a","b","c","a","c","d","a","c","d","a","b","c","a","b","c","b","c","d","a","b","c"))
df
 G C SKU
 1 1   a
 1 0   b
 1 0   c
 2 0   a
 2 1   c
 2 0   d
 3 1   a
 3 0   c
 3 0   d
 4 0   a
 4 1   b
 4 0   c
 5 1   a
 5 0   b
 5 0   c
 6 0   b
 6 1   c
 6 0   d
 7 0   a
 7 1   b
 7 0   c 

I want to find unique "blocks" in this data frame. For example, here we have three blocks: (a,b,c) , (a,c,d) and (b,c,d). I want to create table with these unique blocks, and to sum variable "C" in all "G" for each SKU in certain block. And finally get data frame like this:
     New_G SKU New_C
 1       1   a     2
 2       1   b     2
 3       1   c     0
 4       2   a     1
 5       2   c     1
 6       2   d     0
 7       3   b     0
 8       3   c     1
 9       3   d     0

As I said, here three unique blocks, New_G - identificator of every block, and New_C - the sum of "C" for each SKU that in certain block. (For example, see the first row. SKU = "a", NEW_C = 2  -  it means that in the old data frame SKU "a" while being in the block (a,b,c) has variable "C" = 1 two times) (Another example: see the forth row. Again SKU = "a", but NEW_C = 1 - it means that in the old data frame SKU "a" while being in the block (a,c,d) has variable "C" = 1 once)
If my question is not clear let me now, please. 

A:

You can create an index with toString and use a simple sum by group from there. The challenge is getting the index of unique groups:
ind <- df %>% group_by(G) %>% summarise(temp=toString(SKU)) %>% mutate(fac=as.numeric(as.factor(temp)))
ind <- rep(ind$fac, each=3)
df$ind <- ind
df %>% group_by(ind, SKU) %>% summarise(New_C = sum(C))
# Source: local data frame [9 x 3]
# Groups: ind [?]
# 
#     ind    SKU New_C
#   (dbl) (fctr) (dbl)
# 1     1      a     2
# 2     1      b     2
# 3     1      c     0
# 4     2      a     1
# 5     2      c     1
# 6     2      d     0
# 7     3      b     0
# 8     3      c     1
# 9     3      d     0

Edit
This is possibly quicker:
df %>% group_by(G) %>% 
  mutate(temp=toString(SKU)) %>%
  group_by(temp, SKU) %>%
  summarise(New_C = sum(C))

