Re: [R] sort dates

2012-03-09 Thread Gabor Grothendieck
On Fri, Mar 9, 2012 at 8:35 AM, carol white wrote: > Hello, > How is it possible to sort dates in R? > Your question has already been answered but note that if your data is a time series and you represent it using zoo it will automatically be sorted. Here dates is in reverse chronological order

Re: [R] sort dates

2012-03-09 Thread Robert Baer
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

Re: [R] sort dates

2012-03-09 Thread Petr PIKAL
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-0

Re: [R] sort dates

2012-03-09 Thread R. Michael Weylandt
? sort x <- c(Sys.Date(), Sys.Date() + 1, Sys.Date() - 1) print(x) print(sort(x)) Michael On Fri, Mar 9, 2012 at 8:35 AM, carol white wrote: > Hello, > How is it possible to sort dates in R? > > Cheers, > > Carol > > __ > R-help@r-project.org mailin

[R] sort dates

2012-03-09 Thread carol white
Hello, How is it possible to sort dates in R? Cheers, Carol __ R-help@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, s

Re: [R] sort dates within a factor

2009-10-15 Thread Stefan Uhmann
t;] <- NA Xavier - Mail Original - De: "Stefan Uhmann" À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 13h15:10 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [R] sort dates within a factor Hi Xavier, thank you for your suggestion, it'

Re: [R] sort dates within a factor

2009-09-29 Thread hadley wickham
On Tue, Sep 29, 2009 at 6:58 AM, wrote: > Apologies for the misunderstanding. I can come up with a solution that might > suit your needs: > > library(plyr) > out <- ddply(test, .(nr), function(x) data.frame(date=x$date, > index=rank(-as.integer(x$date > out[is.na(out$nr) | is.na(out$date),

Re: [R] sort dates within a factor

2009-09-29 Thread xavier . chardon
riginal - De: "Stefan Uhmann" À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 13h15:10 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [R] sort dates within a factor Hi Xavier, thank you for your suggestion, it's not exactly what I need. Howe

Re: [R] sort dates within a factor

2009-09-29 Thread Stefan Uhmann
] Xavier - Mail Original - De: "Stefan Uhmann" À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 11h27:20 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: [R] sort dates within a factor Dear List, I have the following data: >> test <- da

Re: [R] sort dates within a factor

2009-09-29 Thread xavier . chardon
Is this what you want? test[order(test$nr, -as.integer(test$date)),] Xavier - Mail Original - De: "Stefan Uhmann" À: r-help@r-project.org Envoyé: Mardi 29 Septembre 2009 11h27:20 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: [R] sort dates withi

[R] sort dates within a factor

2009-09-29 Thread Stefan Uhmann
Dear List, I have the following data: >> test <- data.frame(date = as.Date(c('2007-01-01','2008-03-24','2003-03-02','2008-05-03','2002-05-23','2001-06-30','2005-12-04')), nr = c(2000,2000,2000,2001,2002,2003,2003)) test date nr 1 2007-01-01 2000 2 2008-03-24 2000 3 2003-03-02