[R] Sorting a vector by date
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Sep 12 17:50:10 CEST 2003
On Fri, 12 Sep 2003, Michael Kirschbaum wrote:
> Hello out there....
> Again I have a problem and I stuck...
> How can I sort a vector of dates?
> For example I have the vector
> a<-ISOdate(2001, 1, 1) + 70*86400*runif(10)
> How can this vector be sorted chronological?
> And what's the function I should work with to handle these entries?
> (in sense of: which(a>2001-01-04) or somehting like that)
No function, just make sure you use *dates*, as in
which(a > as.POSIXct("2001-01-04"))
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