title: use loop to calculate basic sum in R
body: <p>I set x=1:2,y=1:2，and I would like to display all x+y outcomes 2 3 4. But it just prints 2 and 4. </p>
  
  <pre><code>x&lt;-0
  for(y in 1:2){
    x&lt;-x+1
    print(y+x)
  }
  # [1] 2
  # [1] 4
  </code></pre>