[R] sorting question

Steve Jaffe sjaffe at riskspan.com
Wed Jul 1 18:58:50 CEST 2009


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,  2005Q1, 2005Q2, etc
some have H1 or H2, some have Q1,Q2,Q3,Q4, some are just plain years. They
should be sorted in the obvious order. I can think of doing something with 
s'trsplit' and 'order' but anyone have anything better?

(I still wonder why sorting with a user-defined function isn't supported.  I
guess I should follow the open source philosophy and contribute my own, but
it seems that would involve implementing an explicit, iterative sort
algorithm, whereas it would make more sense for it to be  integrated with
the internal sort function, if that were possible)

Thanks
-- 
View this message in context: http://www.nabble.com/sorting-question-tp24293430p24293430.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list