Help with ave () function in R

I am new to Rand hope someone can help me with the following:

regarding the command below:

x$rank <- ave(x$fin, x$unique,FUN=rank)

The command works fine, but I want the order x$rankto reverse, so basically, for example, the highest value x$finshows its rank as "10", I need a rank for the largest value should be "1".

In addition, I can have more than one field as a second argument (currently x$unique) if there are multiple fields to make the string unique. If so, how would I structure it.

+4
source share
1 answer

-fin, . , :

x$rank <- ave(-x$fin, x$unique1, x$unique2, FUN=rank)
+5

All Articles