[R] extract certain values from a ts

Gabor Grothendieck ggrothendieck at gmail.com
Tue Oct 24 21:10:08 CEST 2006


On 10/24/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> # Consider the builtin in nhtemp "ts" series
> # Then the runs below above and below the mean are
> r <- rle(as.vector(nmtemp > 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
>
The next statement was supposed to be

tt <- time(nhtemp).

I had started with Nile but then switched to nhtemp since it
gave too much output for an example.

> tt <- time(Nile)
> cbind(tt[idx.first], tt[idx.last])
>
>
> On 10/24/06, antonio rodriguez <antonio.raju at gmail.com> wrote:
> > Hi,
> >
> > Having several daily wind speed time series I want to extract those
> > consecutive days over and below certain values (i.e. 5 < x <8) Don't
> > know which funtion to use (aggregate, lapply?) and how to do it.
> >
> > Thanks in advance
> >
> > Antonio
> >
> > ______________________________________________
> > R-help at 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.
> >
>



More information about the R-help mailing list