title: Ignoring NA in calculation while doing calculation on data frame columns
body: <p>I have a data frame in the form shown below:</p>
  <pre><code>structure(list(First = c(&quot;3.2&quot;, &quot;3.2&quot;, &quot;3.2&quot;, NA, &quot;3.3&quot;, NA, 
  NA), `cut-off` = c(&quot;100000&quot;, &quot;100000&quot;, &quot;100000&quot;, NA, &quot;100000&quot;, 
  NA, NA), Second = c(&quot;1.1&quot;, &quot;1.2&quot;, &quot;1.2&quot;, NA, &quot;1.2&quot;, &quot;1.6&quot;, NA
  ), Bonus = c(NA_character_, NA_character_, NA_character_, NA_character_, 
  NA_character_, NA_character_, NA_character_), Fixed = c(NA, NA, 
  NA, &quot;4000&quot;, NA, NA, NA)), row.names = c(NA, -7L), class = c(&quot;tbl_df&quot;, 
  &quot;tbl&quot;, &quot;data.frame&quot;))
  
  # A tibble: 6 x 5
    First `cut-off` Second Bonus Fixed
    &lt;chr&gt; &lt;chr&gt;     &lt;chr&gt;  &lt;chr&gt; &lt;chr&gt;
  1 3.2   100000    1.1    NA    NA   
  2 3.2   100000    1.2    NA    NA   
  3 3.2   100000    1.2    NA    NA   
  4 NA    NA        NA     NA    4000 
  5 3.3   100000    1.2    NA    NA   
  6 NA    NA        1.6    NA    NA 
  7 NA    NA        NA     NA    NA
  </code></pre>
  <p>What I want to do is calculating a new column called <strong>Total</strong> which will be calculated from the equation shown below:</p>
  <p><code>Total=(First*cut-off/100)+(second*300000/100)+Bonus+Fixed</code></p>
  <p>The problem I have is that based on the situation, a few cells in each row will be NA but I want to ignore NA and considering it as 0 in mathematical calculation (but I can't replace it with 0 as for some cases when all cells in a row are NA, I want to show NA in Total column). So the expeted result for the above dataframe would be:</p>
  <pre><code>  First `cut-off` Second Bonus Fixed   Total
    &lt;chr&gt; &lt;chr&gt;     &lt;chr&gt;  &lt;chr&gt; &lt;chr&gt;
  1 3.2   100000    1.1    NA    NA       6500
  2 3.2   100000    1.2    NA    NA       6800
  3 3.2   100000    1.2    NA    NA       6800 
  4 NA    NA        NA     NA    4000     4000
  5 3.3   100000    1.2    NA    NA       6900
  6 NA    NA        1.6    NA    NA       4800
  7 NA    NA        NA     NA    NA       NA
  </code></pre>
  <p>How can I do this?</p>