Let\'s say I have the following data.table in R:
data.table
R
library(data.table) DT = data.table(x=rep(c(\"b\",\"a\",\"c\"),each=3), y=c(1,3,6)
You can only use - on the numeric entries, so you can use decreasing and negate the ones you want in increasing order:
-
DT[order(x,-v,decreasing=TRUE),] x y v [1,] c 1 7 [2,] c 3 8 [3,] c 6 9 [4,] b 1 1 [5,] b 3 2 [6,] b 6 3 [7,] a 1 4 [8,] a 3 5 [9,] a 6 6