lattice shingle with time and date format
On Tue, Feb 10, 2009 at 6:29 AM, Jon Loehrke <jloehrke at umassd.edu> wrote:
Hi R-Users, I have a time series of bivariate observations (x,y,t). I've developed a few panel routines to explore certain aspects of the data, and now would like to break the time series up into smaller chunks to explore the temporal trends. I would like to know if anyone has any experience breaking up time series with lattice. Base graphics offers coplot, utilizing the co.intervals routine to break up the series into equal chunks. Lattice has equal.count as a wrapper for co.intervals. As you can see in the example below, I can recreate a 'coplot' with lattice but am having difficulty getting the x-axis of the shingle plot and the strip labeling on the xyplot to be in time or date format. My question really consists of two parts, with the second part being less important for my data visualization purposes: 1) How might I be able to convert the x-axis of the shingle plot from numeric to date format?
Perhaps something like plot(breaks, xlim = as.Date(extendrange(breaks), origin = structure(0, class = "Date"))) or the simpler plot(breaks, xlim = extendrange(times)) (the warning seems harmless).
2) How might I be able to customize the strip labels on the xyplot to show a range, like min(month, year)-max(month, year) for each panel?
br.levels <- sapply(levels(breaks),
function(x) {
paste(as.character(structure(x, class = "Date")),
collapse = ", "))
xyplot(y~x|breaks, data=df,
strip = strip.custom(factor.levels = br.levels,
strip.levels = TRUE,
strip.names = FALSE))
You probably want a suitable 'format' in the as.character() call.
-Deepayan