Jsangster
Jsangster

Reputation: 23

Creating a Ranking column R

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

Answers (1)

Orhan Yazar
Orhan Yazar

Reputation: 909

Try Table1$Rank <- rank(Table1$Loss)

You can also use Table1$Rank <- order(Table1$Loss, decreasing = T)

Upvotes: 2

Related Questions