title: Putting print in replicate in R
body: <p>Please look at the following code in R</p>
  
  <pre><code>i=1
  a1=function(x){
    print(i)
    i=i+1
    return(x^2)}
  a2=replicate(5,a1(2))
  </code></pre>
  
  <p>I wish to have an output as <code>1  2  3  4  5</code></p>
  
  <p>Can anyone help me with this? However I don't want to write for-loops. I wish to keep the replicate function as it is. Thanks for suggestions/help.</p>