[Rd] Problem with Axis

Gabor Grothendieck ggrothendieck at gmail.com
Wed Nov 5 17:10:54 CET 2008


If we run the code below we get an error message but if we
replace Axis with axis then we get no error message.

I don't think Axis' error message is a good idea since one
can't know ahead of time whether there is a tick at
January or not since R can automatically adjust plot ranges
in a complex way.  For example, plot(d-13, 1:12) has a tick
at Jan even though d-13 starts at jan 2nd.

I think Axis should act the same as axis in this case.

> d <- seq(as.Date("2008-1-15"), as.Date("2008-12-15"), by = "month")
> plot(d, 1:12, xaxt = "n")
> Axis(side = 1, at = d[2:12], labels = substr(month.abb[2:12], 1, 1))

> Axis(side = 1, at = as.Date("2008-1-1"), labels = "'07")
Error in axis(side, at = z, labels = labels, ...) :
  'at' and 'labels' lengths differ, 0 != 1

> # no error
> axis(side = 1, at = as.Date("2008-1-1"), labels = "'07")

> R.version.string # Vista
[1] "R version 2.8.0 Patched (2008-10-21 r46766)"



More information about the R-devel mailing list