[R] conditional increase by increment
ehlers at ucalgary.ca
Thu Jul 19 19:58:21 CEST 2012
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
> way to alter it slightly so that the increment works on the 0 rather than
> the 1;
> for example:
> the "trip_no" sequence produced would be 1,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3
[It would have been nice if you had included context - not everyone
uses the Nabble interface.]
Bill Dunlap's solution to your problem as originally stated was:
I think that your new requirement is satisfied with
cumsum(c(TRUE, diff(land) == -1))
Unless, of course, I'm misinterpreting something.
> Many thanks
> View this message in context: http://r.789695.n4.nabble.com/conditional-increase-by-increment-tp4636910p4637029.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help