title: adding values to the vector inside for loop in R
body: <p>I have just started learning R and I wrote this code to learn on functions and loops.  </p>
  
  <pre><code>squared&lt;-function(x){
    m&lt;-c()
    for(i in 1:x){
      y&lt;-i*i
      c(m,y)
    }
    return (m)
  }
  squared(5)  
  
  NULL  
  </code></pre>
  
  <p>Why does this return NULL. I want <code>i*i</code> values to append to the end of <code>m</code>and return a vector. Can someone please point out whats wrong with this code.</p>