[Rd] BUG: `lag` returns object of incorrect class

From: Stavros Macrakis <macrakis_at_alum.mit.edu>
Date: Mon, 01 Jun 2009 22:00:19 -0400

In R 2.8.0/Windows:

> lag(1)

[1] 1
[1] 0 0 1

Though this has the 'tsp' attribute, it is of class "integer", and hence not a "time-series object" as defined by ? ts: "time-series objects... are vector [sic] or matrices with class of '"ts"' (and additional attributes)".

? lag further says "Vector or matrix arguments 'x' are coerced to time series", but

> identical(lag(as.ts(1)),lag(1))

[1] FALSE I believe this can be fixed by adding class(x)<-"ts" after line 7 of stats:::lag.default (x <- hasTsp(x)).

Perhaps all other users of hasTsp expect the same behavior? in which case it would better be fixed there.


        [[alternative HTML version deleted]]

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 02 Jun 2009 - 02:04:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 02 Jun 2009 - 08:34:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive