R determines the order of the panel in xyplot()alphabetical order (for strings) or level order (for coefficients). I have dates as text that I would like to display in chronological order, and not in alphabetical order.
x <- sample(1:10, 10, replace = TRUE)
y <- sample(1:10, 10, replace = TRUE)
date <- rep(as.Date("2010-01-01") + sort(sample(200:400, 5)), each = 2)
striptext <- format(date, "%d-%b ...")
df <- data.frame(x, y, date, striptext)
This works great:
xyplot(y ~ x | date, data = df)
But this puts the dates out of order:
xyplot(y ~ x | striptext, data = df)
I do not need the full date in the stripes, but I want them to be in the correct order. Is there any solution beyond what striptextis an ordered factor?
source
share