title: Using function "cat" with "replicate" in R
body: <p>Is there a way how to combine function "cat" with function "replicate" in R?</p>
  
  <p>I want to see number of "loops" R has already made at a particular moment. However, instead of using "for" loop, I prefer to use "replicate". See the simple example below:</p>
  
  <pre><code> Data &lt;- rnorm(20,20,3)
  
   # with for loop
   N &lt;- 1000
   outcome &lt;- NULL
  
   for(i in 1:N){
        Data.boot &lt;- sample(Data, replace=TRUE)
        outcome[i] &lt;- mean(Data.boot)
        cat("\r", i, "of", N)
   }
  
    #the same but with replicate 
    f &lt;- function() {
    Data.boot &lt;- sample(Data, replace=TRUE)
    outcome &lt;- mean(Data.boot)
    return(outcome)
    }
    replicate(N, f())
  </code></pre>
  
  <p>Thus, any ideas how to implement function "cat" with "replicate" (as well as other approaches to see a number of how many times the function of interest has been executed with "replicate") would be very appreciated. Thank you!</p>