If you need to convert the coefficients to numeric, you must, as described in the FAQ, first convert to tna, and then to numeric:
str(z)
#'data.frame': 3 obs. of 2 variables:
# $ a: Factor w/ 3 levels "-2","-4","-7": 1 3 2
# $ b: Factor w/ 3 levels "-1","3","9": 3 1 2
z[order( as.numeric(as.character(z$a)), decreasing=TRUE ), ]
a b
1 -2 9
3 -4 3
2 -7 -1
(Explanation: Factors, unless of course they are βordered factors,β are not ordered, and comparisons with β>β or β<β return NA.
> z$a[1] > z$a[2]
[1] NA
Warning message:
In Ops.factor(z$a[1], z$a[2]) : > not meaningful for factors
, , - , , . )
> z$a
[1] -2 -7 -4
Levels: -2 -4 -7
> as.numeric(z$a)
[1] 1 3 2