I have a data-frame like this:
ID   A   B   C   D
1    1   0   x1  y
1    0   0   x1  y
1    0   0   x1  y
2    0   0   x6  v
2    0   1   x6  v
2    0   0   x6  v
3    0   1   r5  t
3    1   0   r5  t
3    0   0   r5  t
column ID is unique and I want to remove all duplicated and aggregate column A and B by showing max or sum (there could be maximum only one '1' for each ID in column A or B) and display columns C and D that has same value for all unique IDs.
ID   A   B   C   D
1    1   0   x1  y
2    0   1   x6  v
3    1   1   r5  t
by using
aggregate(A~ID,data=df,FUN=sum)
I get only ID and column A but how could I aggregate A and B in the same time and also show columns C and D
 
    