title: Arthematic operations using rasters throwing errors using terra package not with raster package
body: <p>I am trying to do some calculation on raster using following code</p>
  <pre><code>library(terra)
  
  f &lt;- system.file(&quot;ex/elev.tif&quot;, package=&quot;terra&quot;) 
  r &lt;- rast(f)
  
  r_n &lt;- (r - global(r, fun = &quot;min&quot;, na.rm=TRUE))/
    (global(r, fun = &quot;max&quot;, na.rm=TRUE) - global(r, fun = &quot;min&quot;, na.rm=TRUE))
  </code></pre>
  <p>It throws the following error</p>
  <blockquote>
  <p>Error in data.frame(value, row.names = rn, check.names = FALSE) :
  duplicate row.names: 374, 356, 348, 378,...</p>
  </blockquote>
  <p>But if I do it using <code>raster</code> R package, it runs fine like</p>
  <pre><code>library(raster)
  
  r_raster &lt;- stack(r)
  r_n_raster &lt;- (r_raster - minValue(r_raster))/
    (maxValue(r_raster) - minValue(r_raster))
  </code></pre>
  <p>What should I do to make the code run with <code>terra</code> package?</p>