I have a dataset as below and want to reduce it by removing rows. In situation where I have more than 1 ATTACH value for the same exact combination of first three columns, I want to keep only rows that have maximum ATTACH value
BOM = c(rep("BOM1", 1), rep("BOM2", 2), rep("BOM3", 3))
PART = c(rep("A", 3), rep("D", 3))
WW = c(rep("WW01",3),rep("WW05",1),rep("WW06",2))
ATTACH = c(1,4,8,2,2,4)
df1 = data.frame(BOM,PART,WW,ATTACH )
The final output will have row numbers 1,3,4,6 and remaining rows will get deleted