[R] Create order of numbers based on a given vector

syrvn mentor_ at gmx.net
Thu Oct 13 13:15:02 CEST 2011


Hello!

If I have a vector vec <- c(FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE
FALSE)

I can I create the following order of numbers based on vector vec:

1, 2, 2, 3, 3, 3, 4, 5

Whenever there is a FALSE I increase the number (starting with 1).
Whenever there is a TRUE I set the same number as the previous FALSE has
been assigned to.


I would be happy for any input

Cheers,
Syrvn

--
View this message in context: http://r.789695.n4.nabble.com/Create-order-of-numbers-based-on-a-given-vector-tp3901158p3901158.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list