title: How to show the progress bar in raster calc function?
body: <p>how I can use the progress bar like <a href="https://stat.ethz.ch/R-manual/R-devel/library/utils/html/txtProgressBar.html" rel="nofollow" title="this example">this example</a> inside of a function written for use for use in calc raster function?</p>
  
  <p>I have a huge dataset to process and I desire to use the progress bar to control the duration of process. I tryied to use like this, the function (of process) works prefectly, but, do not show the progress bar. </p>
  
  <pre><code># PROGRESS BAR IN CALC RASTER EXAMPLE
  # create data
  r &lt;- raster(nrow=10, ncol=10) 
  dataset &lt;- list() 
  for (i in 1:20) { 
      dataset[i] &lt;- setValues(r, rnorm(ncell(r), i, 3) ) 
  } 
  dataset &lt;- stack(dataset)
  
  ## function to apply
  pixel &lt;-getValuesBlock(s1, row=1, nrows=1, col=1, ncols=1, lyrs=1:nlayers(s1))
  CropAnalysis &lt;- function (pixel, ...){
   gc()
   pb &lt;- txtProgressBar(...)
   # test : if is No data the return is 
   if (identical(x = is.na(pixel), y = rep(TRUE,length(pixel)))) {NA}else{
   averageOfhigher &lt;- mean(pixel[pixel &gt; 10], na.rm=T)
   averageOflower &lt;- mean(pixel[pixel &lt; 10], na.rm=T)
   return(c(averageOfhigher, averageOflower))
   }
   setTxtProgressBar(pb)}
  
   # applying calc finction
   data_process&lt;-calc(x=dataset, fun=CropAnalysis, forcefun=TRUE, forceapply=TRUE)
  </code></pre>