~/ learn/ afm-112/ cards/ order() keeps records together; which.max is a position
1 of 8

In R, type the expression that sorts orders by province A to Z and, within each province, by amount from highest to lowest.

In R, type the expression that sorts orders by province A to Z and, within each province, by amount from highest to lowest.

Answer

orders[order(ordersprov, -ordersamount), ]

order() returns the row positions; the minus sign makes the second key descending. AB 1320, AB 980, BC 640 … The trailing comma keeps all columns.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/0b1f3149-b3dd-4e1e-9a90-9421bc9c55cf/flashcard utf-8 LF