Re: [R] extract certain values from a ts

From: antonio rodriguez <antonio.raju_at_gmail.com>
Date: Wed 25 Oct 2006 - 09:52:49 GMT

Gabor Grothendieck escribió:
> There was still a typo in this so here it is again:
>
> # Consider the builtin in nhtemp "ts" series
> # Then the runs below above and below the mean are
> r <- rle(as.vector(nhtemp > mean(nhtemp)))
> r
>
> # with the first and last indexes of each
> # runs being given by:
>
> idx.last <- cumsum(r$lengths)
> idx.first <- idx.last - r$lengths + 1
>
> # and the first and last times of each run being
>
> tt <- time(nhtemp)
> cbind(tt[idx.first], tt[idx.last])
>
Dear Gabor,

Many thanks! The last two sentences are a very nice solution

Best regards,

Antonio



R-help@stat.math.ethz.ch 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 Wed Oct 25 20:54:39 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 25 Oct 2006 - 11:30:14 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.