[R] sort dates
    Petr PIKAL 
    petr.pikal at precheza.cz
       
    Fri Mar  9 14:51:15 CET 2012
    
    
  
Hi
> 
> Hello,
> How is it possible to sort dates in R?
You mean sort? Or order? Something like:
> dd <-sample(Sys.Date()-1:10)
> dd
 [1] "2012-03-04" "2012-03-05" "2012-02-29" "2012-03-01" "2012-03-02"
 [6] "2012-03-08" "2012-03-03" "2012-02-28" "2012-03-06" "2012-03-07"
> sort(dd)
 [1] "2012-02-28" "2012-02-29" "2012-03-01" "2012-03-02" "2012-03-03"
 [6] "2012-03-04" "2012-03-05" "2012-03-06" "2012-03-07" "2012-03-08"
> dd[order(dd)]
 [1] "2012-02-28" "2012-02-29" "2012-03-01" "2012-03-02" "2012-03-03"
 [6] "2012-03-04" "2012-03-05" "2012-03-06" "2012-03-07" "2012-03-08"
>
Regards
Petr
> 
> 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.
    
    
More information about the R-help
mailing list