On Aug 30, 2011, at 10:00 PM, Markus Weisner wrote:

snipped long preamble:

 Now I have a more complicated
problem and I need help.  Assuming the following factor:


B = as.factor(c("Engine 1", "Engine 10", "Ladder 3", "Engine 3", "Ladder 10",
"Engine 10"))

levels(B)


I would like the factor ordered first by the proceeding unit type and then ordered by the following integer. In this case, I would like to see this order: Engine 1, Engine 3, Engine 10, Ladder 3, Ladder 10. I have tried many different ways of separating out the unit type from the number, but am having trouble figuring out a good way of achieving this factor order. For such a small example, I could obviously manually change the order, but I am
dealing with much larger datasets with many unit types and up to 20
different numbers for each unit type. Having an automated way of ordering these units would be a huge help. Thanks in advance for any help you can
provide.


library(gtools)
?mixedsort


--Markus Weisner

        [[alternative HTML version deleted]]

--

David Winsemius, MD
West Hartford, CT

______________________________________________
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, self-contained, reproducible code.

Reply via email to