[R] Selecting the first occurrence of a value after an occurrence of a different value
surreyj
surreyjackson at gmail.com
Fri Jan 14 10:22:26 CET 2011
Hello everyone,
I am currently working with some data where I need to select the first
occurrence of a value after the occurrence of another value.
The data has two columns, one with a time and one with occurence of certain
events.
The column of data I want to select from looks like this (and each of these
events have a corresponding time in another column).
Stat71
OutMag
FirstResp
InMag
MagUp
OutMag
MagDwn
Resp
Resp
Resp
InMag
MagUp
OutMag
InMag
OutMag
InMag
OutMag
InMag
OutMag
InMag
MagDwn
OutMag
Resp
MagUp
InMag
MagDwn
OutMag
Resp
MagUp
Using "which" I have selected all the individual occurrences of each event
and created variables with the time of said events within them which I used
to calculate differences in time etc for analysis.
But now I am faced with the issue that I need to select only the first
"Resp" that occurs after a "MagDwn" so that I can calculate the differences
in time between these two events.
Any help would be appreciated, usually I just read these forums and try and
figure out problems for myself but this is for my masters and I'm running
out of time to get it finished :)
Thanks
Surrey
--
View this message in context: http://r.789695.n4.nabble.com/Selecting-the-first-occurrence-of-a-value-after-an-occurrence-of-a-different-value-tp3217340p3217340.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list