[R] Specifying Start/End Dates for X-axis Range in plot()/xyplot()
David Winsemius
dwinsemius at comcast.net
Wed Sep 21 04:14:28 CEST 2011
On Sep 20, 2011, at 7:15 PM, Rich Shepard wrote:
> 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
It seems likely even if you got past that error, you would encounter
problems from the hashed up syntax in this portion of that plot call:
z[, $'Burns Mg']
For better guessing, supply the output of:
dput(z) # We have no idea what 'Burns Mg' has in it.
Or just use an example from the zoo pages.
Also: wrapping range() around a vector formed from two elements seems
at the very best unnecessary and at the worst positively fraught with
downside potential. And the 'time' function does not have arguments
names start and stop.
--
David
>
> TIA,
>
> Rich
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list