[R] Newbie question - handling dates as x-axis variable

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Sep 22 17:39:26 CEST 2000

On Fri, 22 Sep 2000, Michael Mastroianni wrote:

> Hi, all.  Please forgive my ignorance
> as I'm just beginning to investigate
> R for use in my company as a primary
> analytical tool ...
> I have data which I've read into a data frame
> with the following command:
> mkt <- read.csv("h:/qdamrtm.csv",header=T)
> I'd like to investigate the relationship(s)
> (or lack thereof) between the given variables,
> and have developed a variety of plots that
> really make me appreciate how powerful
> R is, even when applied in a very rudimentary
> fashion.
> My question is, is there an elegant way to
> treat the date data such that I can plot
> variables against x-axis date labels, specify
> ranges of dates, and calculate differences
> between dates ?  I am beginning to look
> at the packages like "chron" and time series
> information now.  The workaround I've adopted
> merely uses the row index of the data frame
> as the x-axis variable, and I've "pasted" the
> start and end dates into the x-axis title to
> associate the plotted indices with a date
> range (which is a bit of a kludge, I think).
> If I've gleaned anything at all from the R
> documentation, I should be trying to
> treat my data frame as an object to be
> manipulated, and should be able to
> develop functions or procedures which
> allow me to handle dates in a simple
> and direct manner.
> Any advice/guidance/tips are much appreciated
> as I have *tons* of this kind of data to
> cut my teeth on ...

Package chron is along the lines you need.  However, R 1.2.0 will have its
own date/time classes and can do all the things you mention, plus give you
examples to copy, and I think that these will in time supersede chron.
(The time series stuff in package ts is only for regularly-spaced time

Look's like you are on Windows. You can either compile an R-devel
snapshot yourself, or get a pre-compiled one from


(Do read the README first, though, and remember this is a snapshot.)

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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list