I would like to subset, use an aggreate function, AND sort (descending) my table mytable
with 1 short statement. For example, I am counting rows with price > 100 grouped by color, and sorting this by color descending.
I have:
mytable2 <- mytable[price > 100, .N, by = color]
mytable2[order(-color)]
But I would rather have it be in one step. Something like:
mytable[price > 100, .N, keyby = color]
But this is ascending. Simply putting a -
in front of color gives an error. Is there another way? Thanks.