title: How to calculate the median values without NAs?
body: <p>I have a dataframe like this:</p>
  
  <pre><code>df
  name    var1  var2  var3  var4  var5 ...
  site1    10    20    12    5     ..
  site2    15    NA    11    2     ..
  site3    NA    11    21    1     ..
  site4    9     18    NA    6     ..
  </code></pre>
  
  <p>I use this code to calculate the median of the columns.</p>
  
  <pre><code>apply(df[,c(2:4)], 2, median)
  </code></pre>
  
  <p>But it gives NA for columns 2 to 4, because they have NA values. How to exclude the NA values and still calculate medians from the rest data in each column? If use na.rm=T for a subset, all rows with NAs will be removed, which is not what I want. Thanks for helping.</p>