Here is the image of the dataframe:

I have this data frame from a cognitive psych task in which people respond to shapes and sounds. They are meant to always respond in that order, but sometimes they switch but still respond correctly (see second last row for example). I can easily isolate those rows, but I want to transpose the response times so they are in the correct columns. In the example, 1628 which is the response time for the shape stimuli should be in column 'RT1' and the sound response 1462 should be in column 'RT2'.
What function or code can I use to transpose cells given row and column coordinates? Ideally I would use this in the context of an 'if' statement to select the rows in which the responses are transposed.
Hope this makes sense. I cant share the actual data frame.