[R] Inconsistent lattice scales$x$at,label behaviour for POSIXct
Alex Brown
alex at transitive.com
Tue Feb 5 17:37:50 CET 2008
I have encountered the following behaviour in lattice in 2.6.1 (and
2.4.0) which differs depending upon the type you use. I believe the
numeric behaviour to be correct, and the POSIXct behaviour to be in
error.
When the x data and x axis in a lattice graph are POSIXct, and when
using scales$x$at and scales$x$labels to add custom labels:
If the first visible at value is not the first specified at value (due
to x limit settings), the first visible label nonetheless receives the
first specified label, instead of the label corresponding to the first
visible at.
In the following example, at = baseval + 1:4, label = letters[1:4]
I have set it up so that baseval + 1:2 are not visible in the graph
for numeric and Date types, the visible labels are letters[3:4] - ie
"c" "d"
for POSIXct, the visible labels are letters[1:3] - "a" "b".
Simplest to show this by example:
# numeric
baseval=0;
xyplot(1:10 ~ (baseval + 1:10) , scales=list(x=list
(at=baseval+1:4, labels=letters[1:4])),xlim=baseval+c(3,10))
# Date
baseval = as.Date("2007-01-01");
xyplot(1:10 ~ (baseval + 1:10) , scales=list(x=list
(at=baseval+1:4, labels=letters[1:4])),xlim=baseval+c(3,10))
# POSIXct
baseval = as.POSIXct("2007-01-01");
xyplot(1:10 ~ (baseval + 1:10) , scales=list(x=list
(at=baseval+1:4, labels=letters[1:4])),xlim=baseval+c(3,10))
in particular, compare the Date and POSIXct versions
-Alex Brown
More information about the R-help
mailing list