I am trying to use a specific order of a variable in a dataset - valence and - to essentially copy and paste rows into a new dataset. So, for each subID, for every valence = 0, if the next valence = -1 then copy that row to a new dataset called "sequence". The issue is that the trial order was randomized so the sequence is different for each subID (otherwise I'd at least be able to write a big blocky script based on trial number).
Just as an example of what the data looks like:
SubID location valence reaction_time
1 1 0 500
1 1 -1 600
1 0 1 400
1 0 0 500
2 1 1 700
2 1 0 400
2 0 -1 700
2 0 0 400
I'm pretty much a begier at this kind of thing (I'm guessing it needs to be a loop?) and don't have a solid starting point, so any help would be hugely appreciated.
Thanks!
