[R] local sequence function
smu
ml at z107.de
Mon Sep 14 17:20:27 CEST 2009
hey,
I can not find a function for the following problem, hopefully you can
help me.
I have a vactor like this one
v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE)
and I would like to the TRUE values by the their "local sequence
number".
This means, the result should look thike this:
c(NA,NA,1,2,NA,1,NA,1,2,3)
Of course I could solve the problems using a loop, but this would be
much to slow, because the real vector is much larger.
Can you point me in the right direction?
thank you!
regards,
Stefan
More information about the R-help
mailing list