I have a csv formatted input matrix file like:
x y z
a1_b1 0.6 0.44 0.6
a1_b2 0.9 0.1 0.04
a2_b1 0.7 0.02 0.7
a2_b2 0.5 0.4 0.11
From this, I want a row wise calculation of b# values with different combination of a.. The model output for the above matrix be like:
*_b1 *_b2 *_b2-*_b1 Calculate_Positives (for each variable)
x 0.6 0.9 -0.3 =# of positive values for x (in 4th column)/# of x
x 0.7 0.5 0.2
y 0.44 0.1 0.34 =# of positive values for y/# of y
y 0.02 0.4 -0.38
z 0.6 0.04 0.56 =# of positive values for z/# of z
z 0.7 0.11 0.59
I will highly appreciate if anyone suggest any awk/sed/r code for the above.
Please see the model (csv formatted) input and output file below.