[R] window?

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Nov 8 16:41:37 CET 2011



On 08.11.2011 16:26, Kevin Burton wrote:
> Can someone enlighten me on why the following doesn't work?
>
>
>
>
>
> setwd('C:/Temp/R')
>
>
>
> d<- rep(1:53,2)
>
> (s<- ts(d, frequency=53, start=c(2000,10)))
>
> n<- length(s)
>
> k<- n%/%3
>
>
>
> for(i in (n-k):n)
>
> {
>
>      st<- c(start(s)[1] + (start(s)[2] + i)%/%frequency(s), (start(s)[2] +
> i) %% frequency(s))
>
>                  ed<- c(start(s)[1] + (start(s)[2]+k+i)%/%frequency(s),
> (start(s)[2]+i+k) %% frequency(s))
>
>      xshort<- window(s, start=st, end=ed)
>
>                  cat("Start ", st, " End ", ed, "\n")
>
>                  cat("Length ", length(xshort), " start ", start(xshort), "
> end ", end(xshort), "\n")
>
> }
>
>
>
> I get a bunch of warnings like:
>
>
>
> 36: In window.default(x, ...) : 'end' value not changed


Yes, your original s has
End = c(2002, 9)
and you try to set to, e.g.,
c(2002, 45)
in your last iteration which is later and hence cannot be changed.

Uwe ligges





>
>
> Thank you.
>
>
>
> Kevin
>
> rkevinburton at charter.net
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list