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

From: Alex Brown <alex_at_transitive.com>
Date: Wed, 6 Feb 2008 14:42:00 +0000

Here's a related problem that works for numeric but not for POSIXct

I am seeing it where a panel has no at labels, but others do.

This simple example only has one panel with no at labels.

 > baseval = 0;
 > xyplot(1:10 ~ (baseval + c(1:10)), scales=list(x=list + (at=list(c()), labels=list(c()), relation="free")), type="l")

(works)

baseval = as.POSIXct("2007-01-01");
 > xyplot(1:10 ~ (baseval + c(1:10)), scales=list(x=list + (at=list(c()), labels=list(c()), relation="free")), type="l")
Error in as.POSIXct.default(at) :
  do not know how to convert 'at' to class "POSIXlt"

(fails)

-Alex

On 5 Feb 2008, at 20:59, Deepayan Sarkar wrote:

> On 2/5/08, Alex Brown <alex_at_transitive.com> wrote:

>> 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.
>
> Yes, the relevant "POSIXct" method was subsetting 'at' to lie within
> the specified limits but not 'labels'. Should be fixed in the next
> update. Thanks,
>
> -Deepayan
>
>

>> 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.
>>
>
> ______________________________________________
> 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.

______________________________________________
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 Wed 06 Feb 2008 - 15:41:55 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 Wed 06 Feb 2008 - 17:30:12 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