I would like to replace the category column with the category corresponding to the max value in the sales column.

My data looks as follows:

`df <- data.frame(CATEGORY = c("A","A","A","B","B"), SALES = c(10,20,30,40,50))`

I'm looking to fill the CATEGORY variable with "B" since the max value in SALES has a CATEGORY of B

`df <- data.frame(CATEGORY = c("B","B","B","B","B"), SALES = c(10,20,30,40,50))`

If this can be achieved using dplyr syntax I'd be very grateful if anyone could give me a few pointers.

Thanks