Re: Preliminary version of ts package

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

Subject: Re: Preliminary version of ts package
From: Paul Gilbert (pgilbert@bank-banque-canada.ca)
Date: Wed 28 Jul 1999 - 03:55:57 EST


Message-ID: <379DF2AD.3A4DD91E@bank-banque-canada.ca>

Brian

I haven't got far, but here are some initial problems:

> start(1:10)
S: [1] 1 1
ts: 1

> end(1:10)
S: [1] 10 1
ts: 10

window.ts should handle NULL for default start and end values. If it is going
to print a warning then it needs warn=F to suppress the warning. Below is a copy
of my window.ts, but it would require a few minor changes to work without my
tframe library.

Paul
_______

 window.ts <- function (x, start = NULL, end = NULL, warn = T, eps =
.Options$ts.eps)
{
    f <- tsp(x)[3]
    if (is.null(start))
        start <- tsp(x)[1]
    if (is.null(end))
        end <- tsp(x)[2]
    if (2 == length(start))
        start <- start[1] + (start[2] - 1)/f
    if (2 == length(end))
        end <- end[1] + (end[2] - 1)/f
    if (start < tsp(x)[1]) {
        start <- tsp(x)[1]
        if (warn)
            warning("Specified start earlier than start of data, start not
changed.")
    }
    if (end > tsp(x)[2]) {
        end <- tsp(x)[2]
        if (warn)
            warning("Specified end later than end of data, end not changed.")
    }
    leave <- (time(x) >= (start - eps)) & (time(x) <= (end + eps))
    if (is.matrix(x))
        z <- unclass(x)[leave, , drop = F]
    else z <- x[leave]
    classed(ts(z, start = start, end = end, frequency = f), tfclass(x))
}

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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