Preliminary version of ts package
Paul Gilbert
pgilbert@bank-banque-canada.ca
Tue, 27 Jul 1999 13:55:57 -0400
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._