[Rd] start.ts, end.ts (PR#513)

plummer@iarc.fr plummer@iarc.fr
Tue, 11 Apr 2000 12:23:24 +0200 (MET DST)


I'm having trouble with column-subsetting a multivariate time
series.  The underlying problem is with start().

R> x <- ts(matrix(rnorm(100), ncol=2))
R> y <- aggregate(x, ndeltat=2)
R> y[,1]
Error in ts(y, start = start(x), freq = frequency(x)) :
        invalid start
R> start(y)
[1] 2 1
R> frequency(y)
[1] 0.5

The point where the error occurs in ts() is:

    if(length(start) > 1) {
        if(start[2] > frequency) stop("invalid start")
        ...

IMHO the 2-vector notation for the start and end of a time series makes
sense only when the frequency is an integer (and I believe I have said
this before). S-PLUS seems to follow this convention:

S> x <- ts(rnorm(10), start=3, frequency=1/3)
S> start(x)
[1] 3
S> end(x)
[1] 30
S> x <- ts(rnorm(10), start=1/3, frequency=3)
S> start(x)
[1] 0 2
S> end(x)
[1] 3 2

whereas R gives c(0,2) in both cases.

My suggested fix is to edit start.default and end.default, replacing

if(abs(is-round(is)) < ts.eps)

with

if(abs(tsp[3] - round(tsp[3])) < ts.eps && abs(is - round(is)) < ts.eps)

Martyn

--please do not edit the information below--

Version:
 platform = i686-unknown-linux
 arch = i686
 os = linux
 system = i686, linux
 status =
 major = 1
 minor = 0.0
 year = 2000
 month = February
 day = 29
 language = R

Search Path:
 .GlobalEnv, Autoloads, package:base



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