[R] Inconsistent lattice scales$x$at,label behaviour for POSIXct

From: Alex Brown <alex_at_transitive.com>
Date: Tue, 5 Feb 2008 16:37:50 +0000


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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Feb 2008 - 17:35:27 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 05 Feb 2008 - 21:30:11 GMT.

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

list of date sections of archive