s-news
[Top] [All Lists]

Y2K problem

To: s-news@lists.biostat.wustl.edu
Subject: Y2K problem
From: Agin.Patrick@hydro.qc.ca
Date: Thu, 15 Nov 2001 14:45:10 -0500

Hi,

Under Windows NT on Splus 4.5, I try to read a text file which contains in column 1 dates and in column 2 numbers. Here are the first few lines of the file:

    12-Dec-85                                         10.05
    04-Jan-86                                         10.55
    11-Feb-86                                         10.26
    13-Mar-86                                          9.79
    15-Apr-86                                          9.83

    First, I read the data in vec:

    > vec <- scan(file = "D:\\timeseries.txt", what = list("character", numeric()))

    After, I construct an univariate time series with arbitrary sampling time intervals in ts0:

    > ts0 _ its(vec[[2]],times=dates(vec[[1]], format = "day-mon-yr"))
    Error in its(vec[[2]], times = dates(vec[[1]], format = "day-mon-y..: times not in ascending order
    Dumped

As you see, the error message seems to indicate that dates in my file are not in ascending order. I found after many tries that the problem concerns year 2000 dates. The command

       

    > ts0 _ its(vec[[2]][1:2334],times=dates(vec[[1]][1:2334], format = "day-mon-yr"))

returns no error message and
       

    > ts0 _ its(vec[[2]][1:2335],times=dates(vec[[1]][1:2335], format = "day-mon-yr"))

returns the same error message as above. Here is the vector of dates around 2335:

    > vec[[1]][2333:2336]
    [1] "30-Dec-99" "31-Dec-99" "04-Jan-00" "05-Jan-00"
    > dates(vec[[1]][2333:2336],format="day-mon-year")
    [1] 12/30/99 12/31/99 01/04/0  01/05/0


The 2335th element is the first occurence in my file of year 2000. Now, if you sort the vector, the result is:

    > sort(dates(vec[[1]][2333:2336],format="day-mon-yr"))
    [1] 01/04/0  01/05/0  12/30/99 12/31/99

S-Plus seems to consider 01/04/0 as 01/04/1900 (which obviously is less than 12/30/1999). Is there a setting that you can set to tell S-Plus to consider 99 as 1999 and 00 as 2000?

Thank you very much,
Patrick

<Prev in Thread] Current Thread [Next in Thread>
  • Y2K problem, Agin . Patrick <=