title: Summing R Matrix ignoring NA's
body: <p>I have the following claim counts data (triangular) by limits:</p>
  
  <pre><code>claims=matrix(c(2019,690,712,NA,773,574,NA,NA,232),nrow=3, byrow=T) 
  </code></pre>
  
  <p>What would be the most elegant way to do the following simple things resembling Excel's <code>sumif()</code>:</p>
  
  <ol>
  <li>put the matrix into <code>as.data.frame()</code> with column names: "100k", "250k", "500k"</li>
  <li>sum all numbers except first row; (in this case summing 773,574, and 232). I am looking for a neat reference so I can easily generalize the notation to larger claim triangles.</li>
  </ol>
  
  <p>Sum all numbers, ignoring the NA's. <code>sum(claims, na.rm = T)</code> - Thanks for Gregor's suggestion.
  *I played around with the package <code>ChainLadder</code> a bit and enjoyed how it handles triangular data, especially in plotting and calculating link ratios. I wonder more generally if basic R suffices in doing some quick and dirty <code>sumif()</code> or pairwise link ratio kind of calculations? This would be a bonus for me if anyone out there could dispense some words of wisdom. </p>
  
  <p>Thank you!</p>