I have a file with multiple rows and columns tab delimeted such as:
ID v1 v2 v3 v4 v5 v6
A10 -0.2134 -0.190 -0.114 0.400 10.678 -0.123
A115 -0.5038 -0.559 -0.664 0.431 0.139 -0.860
AAAS -0.9072 -0.990 -1.251 3.153 -0.756 0.674
I would like to get the highest absolute number from each row and print if is negative or positive, and also print the header ID from the correspondent column, like:
A10 10.678 v5
A115 -0.860 v6
AAAS 3.153 v4
I was able to calculate the min and max values from each row, but I am not sure how to get the highest absolute values and the ID:
awk 'NR>1{a=0; b=0; for (i=1;i<=NF;i++) if ($i < a || i == 1)a = $i; else if($i > b|| i == 1)b = $i; print $1,a, b}' file
A10 -0.2134 10.678
A115 -0.860 0.431
AAAS -1.251 3.153