[R] sort dates

Robert Baer rbaer at atsu.edu
Fri Mar 9 14:55:13 CET 2012


>How is it possible to sort dates in R?

Try this:
>a = sample(as.Date(1:100, origin = '2012-01-01'),15)
>a
[1] "2012-01-31" "2012-01-22" "2012-03-18" "2012-03-05" "2012-03-17"
[6] "2012-03-08" "2012-01-08" "2012-01-20" "2012-03-01" "2012-03-21"
[11] "2012-02-17" "2012-01-17" "2012-02-12" "2012-02-28" "2012-04-01"
>sort(a)
[1] "2012-01-08" "2012-01-17" "2012-01-20" "2012-01-22" "2012-01-31"
[6] "2012-02-12" "2012-02-17" "2012-02-28" "2012-03-01" "2012-03-05"
[11] "2012-03-08" "2012-03-17" "2012-03-18" "2012-03-21" "2012-04-01"


>Cheers,
>Carol

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


------------------------------------------
Robert W. Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
800 W. Jefferson St.
Kirksville, MO 63501
660-626-2322
FAX 660-626-2965 



More information about the R-help mailing list