Displaying 1 result from an estimated 1 matches for "trip_no".
2012 Jul 18
2
conditional increase by increment
I am trying to assign increasing trip numbers to a binary variable ("land";
1=home and 0=away) where a string of 1's shouldn't increment the trip_no
more than once.
For example; based on
land<-c(0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0)
the "trip_no" sequence produced should be 1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3
This is as far as I can get but Im stumped. In addition I need it to work on
data where the land variable can start on "0&...