Re: [R] conditional increase by increment

2012-07-19 Thread Peter Ehlers
On 2012-07-19 05:56, penguins wrote: Thanks William, that works fantastically! I had a quick play with my data and have realised a potential problem in that if an individual ends the series at home it records an additional trip-no when one wasnt made. I was wondering whether you could think of a

Re: [R] conditional increase by increment

2012-07-19 Thread penguins
Thanks William, that works fantastically! I had a quick play with my data and have realised a potential problem in that if an individual ends the series at home it records an additional trip-no when one wasnt made. I was wondering whether you could think of a way to alter it slightly so that the i

Re: [R] conditional increase by increment

2012-07-18 Thread William Dunlap
essage- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of penguins > Sent: Wednesday, July 18, 2012 10:13 AM > To: r-help@r-project.org > Subject: [R] conditional increase by increment > > I am trying to assign increasing trip numb

[R] conditional increase by increment

2012-07-18 Thread penguins
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,