[R] plot with dates

Halldor Björnsson halldor at vedur.is
Tue Dec 14 16:01:17 CET 2004

I am trying to understand the behaviour of the plot function.
If I have

  novdate <- as.Date("2001/11/1") + (0:29)
  y <- 1:30
  b <- data.frame(novdate,y)

then plot(b$novdate,b$y) will produce a plot where the x-ticmarks are 
given as dates (Nov 04, Nov 09 etc), but plot(b) will produce a plot
where the x-tickmars are integer values (#day since Jan 1st 1970)

In the first case plot is getting a an x-vector of class Date, and 
y-vector of class integer.  In the second case plot gets an object of 
class data.frame (but with components of class Date and integer).

I am new to R so I may be wrong about this, but it seems to me that
different plotting methods are invoked. methods(plot) yields a list of
plot methods, but I cannot access most of them.

Is there a way to guide plot(b) to using the method used by 
plot(b$novdate,b$y), - or is that a bad idea?...


Halldor Bjornsson   (halldor at vedur.is)
Vedurstofa Islands (Icelandic Met. Office)
Bustadavegur 9, IS-150, Reykjavik, Iceland

More information about the R-help mailing list