title: Calculate mean of each column ignoring missing data with awk
body: <p>I have a large tab-separated data table with thousands of rows and dozens of columns and it has missing data marked as "na". For example,</p>
  
  <pre><code>na  0.93    na  0   na  0.51
  1   1   na  1   na  1
  1   1   na  0.97    na  1
  0.92    1   na  1   0.01    0.34
  </code></pre>
  
  <p>I would like to calculate the mean of each column, but making sure that the missing data are ignored in the calculation. For example, the mean of column 1 should be 0.97. I believe I could use <code>awk</code> but I am not sure how to construct the command to do this for all columns and account for missing data.</p>
  
  <p>All I know how to do is to calculate the mean of a single column but it treats the missing data as 0 rather than leaving it out of the calculation.</p>
  
  <pre><code>awk '{sum+=$1} END {print sum/NR}' filename
  </code></pre>