[R] Selecting the first occurrence of a value after an occurrence of a different value
surreyj
surreyjackson at gmail.com
Mon Jan 17 08:09:58 CET 2011
Hello,
Back again,
I thought the problem was solved but I realised that the only reason I was
getting the correct answer was because my data set happened to only have two
"rfts" to choose from, so it looked correct.
I have been using:
onlyfirstresponseafterrft<-which(!diff(as.numeric(factor(Stat, levels =
c("MagDwn", "Resp")))))
> onlyfirstresponseafterrft
[1] 11 12 13 19 20 21 27 28 29 35 36 37 43 44 45 51 52
53
[19] 59 60 61 67 68 69 75 76 77 83 84 85 91 92 93 103 104
105
[37] 113 114 115 121 122 123 129 130 131 137 138 139 145 146 147 153 154
155
[55] 161 162 163 173 174 175 181 182 183 191 192 193 199 200 201 207 208
209
[73] 215 216 217 225 226 227 233 234 235 241 242 243 251 252 253 259 260
261
[91] 267 268 269 275 276 277 283 284 285 291 292 293 303 304 305 311 312
313
[109] 319 320 321 329 330 331 337 338 339
to get my results and what is being delivered is the rows at which a "resp"
occurs after a "magdwn" except I only want the first "resp" after a mag
down... This seems simple to figure out and I have tried a lot of things but
its just not happening!
Can anyone help me please?
Thanks
--
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-tp3217340p3220788.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list