I have a tab-delimited text file where the second column contains in increasing order and includes negative and positive numbers.
I want to assign ranks to the rows based on the value of the second column. The tricky part is that the row where the second column is "0", will be assigned "0", the rows with negative values in the second column ranks of increasingly negative values and the rows with positive values in the second column ranks of increasingly positive values. If two rows have the same value in their second column, they will have the same rank. Example:
Input:
A -5
B -4
C -4
D -2
E 0
F 1
G 1
H 2
Output:
A -5 -3
B -4 -2
C -4 -2
D -2 -1
E 0 0
F 1 1
G 1 1
H 2 2
How do I go about doing this? Thanks!