How do i use the ranking function Row_number with multiple conditions in R

I agree with @rexevan 's approach, with one additional caveat. Unless your data is as small as the reprex, to import the source you will need unique rownames, which your example lacks.