title: How to replace certain values by NA in several rasters before computations?
body: <p>I am making some calculations with raster files.I am particularly calculating the moving average.
  I would like to know hot to assign values to NA before any calculations.</p>
  
  <pre><code>Here is the code :
   files   &lt;- list.files("C:final-2010", "*.envi", full.names = TRUE)
   files[round(files,3) ==  -339999995214436420000000000000000000000.000 ] &lt;- NA
  d1 &lt;-  overlay(stack(files ),fun=function(x) movingFun(x, fun=mean, n=3, na.rm=TRUE))
  </code></pre>
  
  <p>But I got an error:</p>
  
  <pre><code>          Error in round(files, 3) : Non-numeric argument to mathematical function
  </code></pre>
  
  <p>I tried this  also:</p>
  
  <pre><code>  f=stack(files)
    f[round(f,3) ==  -339999995214436420000000000000000000000.000 ] &lt;- NA
     movi &lt;-  overlay(stack(f),fun=function(x) movingFun(x, fun=mean, n=3, na.rm=TRUE))
  </code></pre>
  
  <p>there was no error,but when i looked at the results I found that nothing has been changed.</p>