Skip to content
Back to formatted view

Raw Message

Message-ID: <20050426181050.182dc886.Achim.Zeileis@wu-wien.ac.at>
Date: 2005-04-26T16:10:50Z
From: Achim Zeileis
Subject: Extending time series
In-Reply-To: <10dee469050426085274495f88@mail.gmail.com>

On Tue, 26 Apr 2005 11:52:00 -0400 Fernando Saldanha wrote:

> I noticed that when one tries to extend a time series (ts) object by a
> single period using window() actually two observations (NAs) are
> added. See below for an example. Does anyone know the reason for this
> behavior and how to avoid it?

Yes:
  end(x) + 1
is not what you expect it to be. You can set equivalently
  end = 4
  end = c(4, 1)
to achieve what you want and you can compute one of those
representations in various ways, e.g., tsp(x)[2] + 1.
Z

 
> Thanks.
> 
> FS
> 
> > x<-ts(c(1,2,3))
> > x1<- window(x, start(x), end(x) + 1, extend = TRUE)
> > x1
> Time Series:
> Start = 1 
> End = 5 
> Frequency = 1 
> [1]  1  2  3 NA NA
> 
> ______________________________________________
> 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
>