How to handle missing data in calculation of new column using awk?
I want to add a new column with values equal to -log of values in the 3rd
column. But, there are fields filled with NA. I used the below code that
as expected outputs inf for these fields.
awk 'NR!=1 {print $1, $2, $3, -1*(log($10))}' t1
File
1 rs3 0.341
2 rs4 NA
3 rs5 0.599
4 rs6 NA
Desired output
NEW COLUMN
1 rs3 0.341 1.047
2 rs4 NA NA
3 rs5 0.599 0.512
4 rs6 NA NA
How can I keep NA in the new column?
Thank you
No comments:
Post a Comment