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
[email protected]
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.
______________________________________________
[email protected] 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.