I am new to using R, and I am having hard time trying to rank dataframe using two columns in R. The data is in the form of this.
A B
1 1
2 1
2 1
4 4
5 3
I want result to be in the form of
A B Rank
1 1 1
2 1 2
2 1 2
4 4 5
5 3 4
which is ranked by B first, and the A is used to rank if there is equal value in B. I think my question is very similar to How to rank rows by two columns at once in R? and I tried the answers for this, but this didn't work for me.