[R] formatting POSIXlt object as strip labels in lattice plot
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Nov 23 05:04:56 CET 2007
Create a custom strip function which changes the names
of the factor levels. Here we have changed them from 1:2
to c("b", "a").
my.strip <- function(..., factor.levels) {
factor.levels <- c("b", "a")
strip.default(..., factor.levels = factor.levels)
}
x <- 1:10
y <- x*x
z <- gl(2, 5)
xyplot(y ~ x | z, strip = my.strip)
On Nov 22, 2007 10:42 PM, John Field <JohnField at ozemail.com.au> wrote:
> Dear list,
>
> I'm plotting a lattice plot
>
> xyplot(Volume ~ Weight | as.character(DateTime))
>
> where DateTime is a POSIXlt object. This produces strip labels in
> the format e.g. "2007-11-15 23:15:00" and panels are plotted in the
> correct order. I'd prefer a format "15 Nov 23:15", but if I use
> format(DateTime,format="%d %b %H:%M") to do the conversion, then the
> panels are ordered according to the day of the month, ie the
> character string "15 Nov 23:15" etc.
>
> How do I get labels in the required format, but panels in the correct order?
>
> Thanks,
> John
>
> =========================
> John Field Consulting Pty Ltd
> 10 High Street, Burnside SA 5066
> Phone 08 8332 5294 or 0409 097 586
> Fax 08 8332 1229
> Email JohnField at ozemail.com.au
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list