[R] Date on x-axis of xyplot
Charles H. Franklin
franklin at polisci.wisc.edu
Wed Sep 17 06:43:59 CEST 2003
>On Tuesday 16 September 2003 22:00, Charles H. Franklin wrote:
>> xyplot doesn't seem to want to label my x-axis with dates but instead
>> the day-number for each date.
>> What am I missing?
Deepayan Sarkar replies:
>The fact that xyplot doesn't know anything about the "date" class. I'm not
>familiar with the date package, but the docs and a few experiments seem to
>indicate that an object of class "date" is simply a numeric/integer vector
>with the class attribute set to "date". xyplot interprets it as plain
>You may be able to get what you want by
>print(xyplot(pct ~ factor(as.character(begdate)) | names, pch=2, cex=.2,
> prepanel = function(x, y) prepanel.loess(x, y, span = 1),
>(but this will try to label all unique dates, which may not be good).
>Is the date class standard enough to warrant including a check for it in
OK. I was afraid of that.
I'm not sure how standard the date class is. Or if there is an alternative
that is better. But I DO think that being able to label dates in some way on
the x-axis would be a common enough problem to be worth solving. This is
especially an issue when data are irregularly spaced and so time series
plots are not appropriate. As it stands, my graphs are labeled 15650 to
15950, which is surely not intuitive to anyone!
Many thanks to Deepayan for the Lattice package and his support of it. It is
so great that I just want one more thing...!
More information about the R-help