Re: [R] R: ts - objects (PR#228)

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [R] R: ts - objects (PR#228)
From: Martyn Plummer (plummer@iarc.fr)
Date: Thu 15 Jul 1999 - 23:03:56 EST


Message-ID: <XFMail.990715150356.plummer@iarc.fr>

> Marcus Eger <marcus.eger@physik.uni-marburg.de> writes:
>>
>> -----------------------------------------------------------------------------
>> 3. Another problem had to do with the value of delta and/or start:
>> -----------------------------------------------------------------------------
>> > time(ts(c(1,2,3,4),start=3,delta=1.5))
>> Error: invalid start
>
> or just:
>
>> ts(c(1,2,3,4),start=3,delta=1.5)
> Time Series:
> Start = c(3, 1)
> End = c(7, 1)
> Frequency = 0.666666666666667
> Error: invalid start
>
> ..which is pretty darn weird! CC'ed to R-bugs.

That's just the print method for ts objects calling
time().

The underlying problem is in start().
> start(x)
[1] 3 1

I think the 2-vector form of start and end only makes sense when the
frequency is an integer. If I am right then the following versions of
start.ts and end.ts (which check that tsp[3] is an integer) should solve
the problem.

M.

"start.ts" <- function (x)
{
    ts.eps <- .Options$ts.eps
    ##if(is.null(ts.eps)) ts.eps <- 1.e-5
    tsp <- attr(as.ts(x), "tsp")
    is <- tsp[1] * tsp[3]
    if (abs(tsp[3] - round(tsp[3])) < ts.eps && abs(is - round(is)) <
        ts.eps) {
        is <- floor(tsp[1])
        fs <- floor(tsp[3] * (tsp[1] - is) + 0.001)
        c(is, fs + 1)
    }
    else tsp[1]
}

"end.ts" <- function(x)
{
    ts.eps <- .Options$ts.eps
    ## if(is.null(ts.eps)) ts.eps <- 1.e-5
    tsp <- attr(as.ts(x), "tsp")
    is <- tsp[2] * tsp[3]
    if (abs(tsp[3] - round(tsp[3])) < ts.eps && abs(is - round(is)) <
        ts.eps) {
        is <- floor(tsp[2])
        fs <- floor(tsp[3] * (tsp[2] - is) + 0.001)
        c(is, fs + 1)
    }
    else tsp[2]
}

M.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:06 EST