[R] Regular time series with irregular start and end dates

Wesley Roberts WRoberts at csir.co.za
Thu Oct 28 13:02:39 CEST 2010


Dear Gabor,

Many thanks for your suggestions, I could not get "seq(as.Date("2005-09-13"), as.Date("2006-10-15"), by = 16)" to work with ts so have chosen to use the zooreg solution you suggested. In the end, all I want to do is graph the values with the correct time scale on the x-axis. Later we may think about time series analyses.

Once again, many thanks.
Wesley


>>> Gabor Grothendieck <ggrothendieck at gmail.com> 27/10/2010 16:38 >>>
On Wed, Oct 27, 2010 at 10:01 AM, Wesley Roberts <WRoberts at csir.co.za> wrote:
> Dear R users,
>
> I have a quick question regarding creating an index for a zoo object. I am using R 2.12 on winxp.
>
> I have read through the R archives searching for information on dates and time series analysis and nothing seems to cover my question.
>
> I am extracting data from a time series of remote sensing data. The frequency of the data is 16 days which means I cant use ts (ts likes months single days etc) and have thus been trying to replicate the following dates using ISOdatetime.
>
> 09/13/2005 09/29/2005 10/15/2005 10/31/2005 11/16/2005 12/02/2005 12/18/2005
>
> So far, the only method I have found to be successful is the following
>
> a<-ISOdatetime(2005, 9, c(13,29), 0, 0, 0)
> b<-ISOdatetime(2005, 10, c(15,31), 0, 0, 0)
> c<-ISOdatetime(2005, 11, c(16), 0, 0, 0)
> d<-ISOdatetime(2005, 12, c(2,18), 0, 0, 0)
>
> e<-c(a,b,c,d)
>> sort(e)
> [1] "2005-09-13 SAST" "2005-09-29 SAST" "2005-10-15 SAST" "2005-10-31 SAST"
> [5] "2005-11-16 SAST" "2005-12-02 SAST" "2005-12-18 SAST"
>
> This is obviously highly convoluted and is not an appropriate solution.
>
> I would appreciate some advice as to how I would go about creating an index that starts at date 2005-09-13 and creates the next date 16 days ahead till the finishing date 2006-10-15. Also, given the nature of my time series would I be able to use ts instead of zoo?
>

Try this:

   seq(as.Date("2005-09-13"), as.Date("2006-10-15"), by = 16)

or if the reason you want this is that you have 25 values and want to
make a zoo/zooreg series from them starting at the indicate Date then
just do this (were we use 1:25 for the values of the series for
purposes of example):

   zooreg(1:25, as.Date("2005-09-13"), deltat = 16)




-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com


-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.



More information about the R-help mailing list