From: Simon Wotherspoon (Simon.Wotherspoon@utas.edu.au)
Date: Mon 24 Mar 2003 - 15:17:41 EST
Message-id: <JPEJIEHCLCCMMBFGMPDGGEJJCCAA.Simon.Wotherspoon@utas.edu.au>
Hi,
In 1.6.2 at least, when constructing a sequence of dates with seq and the
by argument inherits from difftime, the "units" attribute seems to be
ignored. E.g.
try
str <- strptime("23/3/2003 06:00:00","%d/%m/%Y %H:%M:%S")
end <- strptime("23/3/2003 06:02:00","%d/%m/%Y %H:%M:%S")
step <- strptime("23/3/2003 06:01:00","%d/%m/%Y %H:%M:%S") -
strptime("23/3/2003 06:00:00","%d/%m/%Y %H:%M:%S")
seq(str,end,step)
A possible fix is to replace the lines
if (inherits(by, "difftime")) {
by <- unclass(by)
}
in seq.POSIXt with
if (inherits(by, "difftime")) {
by <- switch(attr(by, "units"), secs = by, mins = 60 * by, hours = 60 *
60 * by, days = 60 * 60 * 24 * by, weeks = 60 * 60 *
24 * 7 * by)
}
as in "-.POSIXt", but this may not be the best solution.
I can't really see the point of representing difftime objects in terms of
different units, given POSIXct is always stored as seconds. Would it be
better to move the whole "unit" business into a print method, more or less
as it is for POSIXct?
Simon.
---______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:26 EST