R-alpha: $tsp

Ross Ihaka (ihaka@stat.auckland.ac.nz)
Wed, 3 Apr 1996 11:42:24 +1200


Date: Wed, 3 Apr 1996 11:42:24 +1200
From: Ross Ihaka <ihaka@stat.auckland.ac.nz>
Message-Id: <199604022342.LAA08086@stat.auckland.ac.nz>
To: R-testers@stat.math.ethz.ch
Subject: R-alpha: $tsp
In-Reply-To: <96Apr2.150659est.29463@mailgate.bank-banque-canada.ca>

Paul Gilbert writes:
 > 
 > attributes and attr seem to report $tsp incorrectly:
 > 
 > > z <- ts(0.1 *(1:100), start=c(1961,1), freq=12)
 > > tsp(z)
 > [1] 1961.00 1969.25   12.00
 > > attr(z, "tsp")
 > [1] 23532 23631    12
 > > attributes(z)
 > $tsp
 > [1] 23532 23631    12
 > 
 > $class
 > [1] "ts"
 > 
 > 
 > This messes up storage.mode as used by lsfit, which seems to object to
 > an invalid tsp attribute (Error: invalid time series parameters
 > specified).

This probably makes a little more sense when you see that

	23532 / 12  = 1961  and  23631 / 12 = 1969.25

What I would like to do is get rid of the inexact comparisons which S
makes when comparing times.  This is what the ts.eps parameter is
about.  I'd rather store times as multiples of the underlying sampling
interval, comparisons of times can be made using exact integer
arithmetic.  Of course this places some restrictions on the range that
time values can take on, but +/- 3 million years of daily observations
should suffice for most puposes :-).

This supposes that access to the underlying attribute is through the
accessor functions tsp() and tsp<-() rather than directly through the
slot $tsp.

I'm not overly wedded to the idea, it just seems much cleaner.
	Ross
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-