R: How to make the first occurrence of a number into NaN within a group

I'm currently trying to make the row of the first time a subject selects the blue cue into NaN in R. How do I replace the value of the first occurrence of a value within a group (the subject group) with NaN? I tried to do the following:


When I do this, it new dataset only has the NaN values and not the rest of the rows.