[R] Plot.date and legends

Bryan Sykes BSykes at NBME.org
Fri Mar 10 15:29:49 CET 2006


Hi:

I'm trying to plot dates on the x-axis of a code, but the legend is not being
displayed.  I receive the following error:

Error in match.arg(x, c("bottomright", "bottom", "bottomleft", "left",  : 
        'arg' should be one of bottomright, bottom, bottomleft, left,
topleft, top, topright, right, center
In addition: Warning message:
longer object length
        is not a multiple of shorter object length in: arg == choices

The problem is that I have more than one trend line, and the legend doesn't
seem to work given that the x-axis is a date.  I've searched prior help
threads, but this issue hasn't come up.  Any ideas?  A sample code can be
found below.

date <-
as.date(c("15-Jan-06","22-Jan-06","29-Jan-06","5-Feb-06","12-Feb-06","19-Feb-
06","26-Feb-06"))

par(mfrow=c(2,1))
plot.date (date, int_median, main="Median Time to Receive Outcome Files, 
           International and Domestic Centers Week", xlab="Week", 
           ylim=c(15,35), ylab="Median Hours", type = "l",lwd =1, lty=1)
lines (date, dom_median, type = "l", lwd = 2, lty=2)
abline(h=24, lwd=2)
name <- c("International", "Domestic")
legend (c("29Jan6","5Feb6"),c(26,35), name, lwd=c(1,2), lty=c(1,2))

plot.date (date, int_mean, main="Mean Time to Receive Outcome Files, 
           International and Domestic Centers Week", xlab="Week", 
           ylim=c(15,35), ylab="Median Hours", type = "l",lwd =1, lty=1)lines
(date, dom_mean, type = "l", lwd = 2, lty=2)
abline(h=24, lwd=2)


Thanks,

Bryan L. Sykes
Program Associate, Operations Research
National Board of Medical Examiners
bsykes at nbme.org




More information about the R-help mailing list