Re: [R] sorting question

2011-01-11 Thread Albert-Jan Roskam
s ever done for us? ~~ To: R Mailing List Sent: Tue, January 11, 2011 12:11:01 PM Subject: [R] sorting question Hi, I have a data frame with variables a, b, c (character vars) and t (time var, could be represented as POSIXct or character, depending on which is most useful. The

[R] sorting question

2011-01-11 Thread Albert-Jan Roskam
Hi, I have a data frame with variables a, b, c (character vars) and t (time var, could be represented as POSIXct or character, depending on which is most useful. The format is "-mm-dd hh:mm:ss CET"). Now, I want to sort the data frame in ascending order by a, b, c and then in descending or

Re: [R] sorting question

2009-07-01 Thread Gabor Grothendieck
This maps each string to one of the form yearQqtr at which point you can sort them. Modify the mapping as necessary. > library(gsubfn) > dd <- c("2002", "2003H1", "2003H2", "2004", "2005Q1", "2005Q2") > gsubfn("H.|Q.|$", list(H1 = "Q1", H2 = "Q2", Q2 = "Q2", Q3 = "Q3", Q4 = "Q4", > "Q1"), dd)

Re: [R] sorting question

2009-07-01 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Steve Jaffe > Sent: Wednesday, July 01, 2009 9:59 AM > To: r-help@r-project.org > Subject: [R] sorting question > > > I've asked about custom so

[R] sorting question

2009-07-01 Thread Steve Jaffe
I've asked about custom sorting before and it appears that -- in terms of a user-defined order -- it can only be done either by defining a custom class or using various tricks with "order" Just wondering if anyone has a clever way to order "vintages" of the form 2002, 2003H1, 2003H2, 2004, 2005Q