In S-Plus 6.0 (and perhaps earlier) there is a powerful
date-time variable class called
timeDate. Through the scales=list(x=...) option to xyplot
it is possible to plot date-time variables fairly easily
nTimeDate <- function(x, ...) {
if(!inherits(x,'timeDate')) stop('x is not a timeDate variable')
u <- axis.time(range(x,na.rm=T),
skip.weekends=F, ...)$grid
at <- list(at=as.numeric(u$major.grid$x),
labels=format(u$major.grid$x))
# minor tick locations: u$minor$x
x <- as.numeric(x)
attr(x,'scale') <- at
x
}
x <- nTimeDate(mytimeDatevar) # convert to ordinary numeric
xyplot(y ~ x, scales=list(x=attr(x,'scale')))
scales= will label the x-axis nicely, using the fairly well-chosen
time intervals selected by axis.time. axis.time also computes
positions for minor tick marks (see comment above).
These may be aligned to quarters, months, or weeks. How would
one specify the minor tick x-axis locations to trellis?
I don't want to use a low-level routine such as axis( ) as
multiple panels may be present.
--
Frank E Harrell Jr Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat
|