Reputation: 23
I have a data frame (Table1) with 2 columns, "Year" and "Loss". I want to Create a new column "Rank" that ranks the losses. Largest value in the Loss column should rank 1.
Upvotes: 1
Views: 6264
Reputation: 909
Try Table1$Rank <- rank(Table1$Loss)
You can also use Table1$Rank <- order(Table1$Loss, decreasing = T)
Upvotes: 2