逆順ソート
> f1 = function() arrange(aq, desc(Ozone))
>
> # 逆順は decreasing=TRUE
> f2 = function() {
+ d = aq[order(aq$Ozone, decreasing=TRUE),]
+ rownames(d) = NULL
+ d
+ }
>
> # または,数値変数なら符号付け替え(desc がやっていること)
> f3 = function() {
+ e = aq[order(-aq$Ozone),]
+ rownames(e) = NULL
+ e
+ }
> a = f1()
> identical(a, f2())
[1] TRUE
> identical(a, f3())
[1] TRUE
>
> # order を使う方が若干速い
> benchmark(f1(), f2(), f3(), columns=c("test", "replications", "elapsed", "relative", "user.self", "sys.self"), replications=1000, order=NULL)
test replications elapsed relative user.self sys.self
1 f1() 1000 5.340 1.011 5.174 0.201
2 f2() 1000 5.282 1.000 5.103 0.223
3 f3() 1000 5.308 1.005 5.079 0.261