I have a file of 5 columns:
1 1311 2 171115067 1.1688e-08
1 1313 3 171115067 1.75321e-08
1 1314 4 171115067 2.33761e-08
2 1679 5 135534747 3.68909e-08
2 1680 2 135534747 1.47564e-08
3 688 34 191154276 1.77867e-07
3 689 38 191154276 1.98792e-07
3 690 39 191154276 2.04024e-07
I need to sum the multiplication of ($2*$3) then divid it by distinct value of $4 for each range of $1
So, as an example:
within value 1 in $1, I should have: [1311*2+1313*3+1314*4]/171115067 for 2 in $1: [1679*5+1680*2]/135534747
And so on till the end (not necessary just to 3), so at the end sum the results of each value range
What I tried is: awk '{sum+=($2*$3)/$4} END { print "Result = ",sum}'
but that give me the sum of the multiplication for all together divided by each time which not what I need
Any help with that please?
Aucun commentaire:
Enregistrer un commentaire