[R] correct my method of estimating mean of two POSIXlt data frames

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Oct 5 22:13:05 CEST 2004

On Tue, 5 Oct 2004 "gotrout at gmail.com" (but with no name nor signature)

Quoting someone without credit (and therefore in breach of their 

> > If a.lt and b.lt are the two vectors of POSIXlt dates then try
> > converting each to POSIXct and unclassing to make each numeric.
> > Take the mean of the two numeric vectors and convert them back to
> I see.  I'm a little confused with the use of class/unclass versus
> as.XX.  For example, instead of using unclass, why wouldn't I use
> as.numeric?  Could someone explain the difference?

That advice is wrong: you should not be unclassing before forming the
mean as mean() has a method for 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