title: R function with FOR loop on a vector
body: <p>Surely a facepalm question, sorry. I have been trying to RTFM and google that but no luck.</p>
  
  <p>I am trying to make a silly function in R that takes a vector as argument, loops through it with a for loop and does a very simple addition to each component. </p>
  
  <pre><code>func1 &lt;- function(vector) {
    vr &lt;- c() ### an empty vector 
  
    for (i in 1:length(vector)) { 
      vr &lt;- vector[i]+i
    }
  }
  </code></pre>
  
  <p>To me this looks correct, but I am always getting a NULL vector. Why? </p>