[R] Using dates for plotting

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jan 16 12:40:55 CET 2004


On Fri, 16 Jan 2004, Christoph Lange wrote:

> 
> Dear R-Users!
> 
> I have the following data:
> 
> > runs
> dates kms
> 1 2004-01-15 12:00:00   9
> 2 2004-01-16 12:00:00  10
> 3 2004-01-17 12:00:00   5
> > class(runs$dates)
> [1] "POSIXt"  "POSIXct"
> > 
> 
> Is it possible to _easily_ plot these data with real dates shown as
> tick marks on the x-axis? Perhaps even when the days are not
> continuous but with missing days in between?

Yes.  ?plot.POSIXct has examples like

     plot(.leap.seconds, 1:22, type="n", yaxt="n",
          xlab="leap seconds", ylab="", bty="n")
     rug(.leap.seconds)

What could be easier?  If you want only the data dates labelled, use
axis.POSIXct.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list