[R] Specifying Start/End Dates for X-axis Range in plot()/xyplot()

Rich Shepard rshepard at appl-ecosys.com
Wed Sep 21 01:15:12 CEST 2011


   I'm having difficulty finding the syntax to use to specify the beginning
and ending dates for the x-axis while plotting a zoo object. I thought that
I had seen a message on this list that used start=as.Date("...")
end=as.Date("..."), but I cannot find that message. I've tried ?plot,
?plotxy, ?plot.zoo, and Sarkar's lattice book.

   I am trying to plot the time series for 'Burns Mg' generated by:

> sapply(names(z), function(nm) range(time(na.omit(z[, nm]))), simplify = FALSE)
$`Burns Mg`[1] "1994-01-20" "2009-11-11"

   This is a typical result of my trial-and-error approach:

> plot(z[, $'Burns Mg'], range(time(start = as.Date("1994-01-20"), end = as.Date("2009-11-11"))))
Error in is.matrix(x) : 'x' is missing

   Please point me to documentation on specifying

TIA,

Rich



More information about the R-help mailing list