I have file like this (Tab Separated)
Name Data1 Data2 Extra A B C D
Test1 A C 40 23 10 12 5
Test2 B C 20 13 3 32 5
Test3 C D 44 43 0 1 5
Test4 A D 43 2 7 0 5
I need add column called frequency based on this Data1 and Data2. Freq= Data2 value/ (Data2 value+ Data1 value). For example for the Test1 Freq = 12/(12+23)
It will be easy to calculate and add values like this (for the row where Data1="A" and Date2="C"
awk '{print$7/($5+$7)}‘
But How can I select the column based on the row value ?
Expected out
Name Data1 Data2 Extra A B C D Freq
Test1 A C 40 23 10 12 5 0.34
Test2 B C 20 13 3 32 5 0.91
Test3 C D 44 43 0 1 5 0.83
Test4 A D 43 2 7 0 5 0.71