Re: [R] Max consecutive increase in sequence

From: Ingmar Visser <i.visser_at_uva.nl>
Date: Tue, 13 May 2008 23:30:23 +0200

rle(diff(sq)) could be helpful here,
best, Ingmar

On May 13, 2008, at 11:19 PM, Marko Milicic wrote:

> Hi all R helpers,
>
> I'm trying to comeup with nice and elegant way of "detecting"
> consecutive
> increases/decreases in the sequence of numbers. I'm trying with
> combination
> of which() and diff() functions but unsuccesifuly.
>
> For example:
>
> sq <- c(1, 2, 3, 4, 4, 4, 5, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1);
>
> I'd like to find way to calculate
>
> a) maximum consecutive increase = 3 (from 1 to 4)
> b) maximum consecutive decrease = 5 (from 6 to 1)
>
> All ideas are highly welcomed!
>
>
>
>
>
> --
> This e-mail and any files transmitted with it are confid...
> {{dropped:14}}
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 13 May 2008 - 21:34:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 14 May 2008 - 06:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive