[R] Dates labels on axes in xyplot
Dirk Eddelbuettel
edd at debian.org
Wed Feb 9 05:57:07 CET 2005
On 9 February 2005 at 14:37, Denham Robert wrote:
| I am a bit confused about how to get the format of the labels in xyplot
| to show as dates rather than the numeric value.
|
| e.g.,
|
| x <- as.Date(c("20/01/2001","20/02/2003","21/06/2004"),"%d/%m/%Y")
| y <- c(1,2,3)
|
| plot(y~x) #produces formatted labels
|
| xyplot(y~x) #doesn't give formatted x labels
|
| xyplot(y~x,scales=list(x=list(format="%d/%m/%Y"))) #still doesn't.
|
| How do I get the format for the xlabels ?
You need another as.POSIXct():
> x <- as.POSIXct(as.Date(c("20/01/2001","20/02/2003","21/06/2004"),"%d/%m/%Y"))
> y <- c(1,2,3)
> xyplot(y~x)
Dirk
--
Better to have an approximate answer to the right question than a precise
answer to the wrong question. -- John Tukey as quoted by John Chambers
More information about the R-help
mailing list