title: Sum of even number using given range in R
body: <p>I am trying to get sum of even numbers in R Using this code:</p>
  
  <pre><code>x&lt;- c(80:100)
  for(i in x) {
    if(i%%2==0) b&lt;-append(b,i)
  }
  sum(b)
  </code></pre>
  
  <p>But I am not getting perfect answer.
  When I print b after the if statement I get b as:</p>
  
  <blockquote>
    <p>[1] 100  80  82  84  86  88  90  92  94  96  98 100</p>
  </blockquote>
  
  <p>why the first index is coming 100.</p>