[Rd] diff.default / diff.ts in wrong package bug (PR#640)
maechler@stat.math.ethz.ch
maechler@stat.math.ethz.ch
Tue, 22 Aug 2000 18:36:18 +0200 (MET DST)
>>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch> writes:
MM> {all recent versions of R} Problem / design bug :
MM> diff.default() doesn't deal with "ts" objects properly, diff.ts()
MM> does, but that is only available from package "ts" where as the
MM> constructor function ts() is in base.
MM> It's not sufficient to just move diff.ts() to package base, since
MM> it relies itself on lag & lag.default which are also only in
MM> package ts.
MM> ----------------------------------------------------
MM> A simple example :
>> diff(ts(1:50, start= 1980, frequency = 12))
MM> Error in tsp<-(*tmp*, value = c(xtsp[1] + lag * differences *
MM> xtsp[3], : invalid time series parameters specified
>> library(ts)
>> diff(ts(1:50, start= 1980, frequency = 12))
MM> Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 1980 1 1 1 1 1
MM> 1 1 1 1 1 1 1981 1 1 1 1 1 1 1 1 1 1 1 1 1982 1 1 1 1 1 1 1 1 1 1 1
MM> 1 1983 1 1 1 1 1 1 1 1 1 1 1 1 1984 1 1
---
answering myself :
One easy and "clean" fix is to put the following at the very beginning of
diff.default :
if(is.ts(x)) {
require(ts)
UseMethod("diff")
}
{and then remove the "tsp" stuff at the end of diff.default()}.
Now
diff(ts(1:20))
gives a one line message
-------------------------------------
Loading required package: ts
-------------------------------------
but I think this is really okay and desired to some extent.
As Prof Ripley pointed out in a private e-mail to me,
package ts should really be used for everything "ts"ish,
but then we want to have very basic "ts" functionality in package base...
The above passes "make check" (and more).
Anybody against this?
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._