I have a test dataframe df from which I want to drop duplicate values in the Hits column but not the rows associated with the duplicate values. The condition however is that the dropping is to be done only in some specific ranges of row indices.
df <- data.frame(
Hits = c("#a", "#ID:987129470", "#b", "Hit1", "Hit1", "Hit2", "Hit3", "Hit3", "#a", "#ID:6971324987", "#b", "Hit1", "Hit2", "Hit2", "Hit3"),
Category1 = c(NA, NA, NA, 0.001, 0.001, 0.002, 0.003, 0.003, NA, NA, NA, 0.023, 0.341, 0.341, 0.569),
Category2 = c(NA, NA, NA, 100, 100, 99, 98, 98, NA, NA, NA, 100, 95, 95, 97),
Category3 = c(NA, NA, NA, 100, 100, 99, 98, 98, NA, NA, NA, 98, 97, 97, 92))
df looks like this
The ranges of row indices in which the dropping operation is to be carried out are 4:8 and 12:15 in this case. Basically, the duplicate hits under each ID are to be dropped, keeping the associated values in the other columns intact. The output should look something like this
In the original dataframe (which has ~100k rows!) it is not possible to specify the ranges. How do I solve this issue?

