title: How do you change coordinates of a raster?
body: <p>I want to use something like </p>
  
  <pre><code>library(raster)
  library(sp)
  
  ## Create raster
  r &lt;- raster(ncol=40, nrow=20)
  class(r)
  
  ## display coordinates
  coordinates(r)
  
  ## create new coordinates
  x &lt;- matrix(rexp(200, rate=.1), ncol=40, nrow=20)
  y &lt;- matrix(rexp(200, rate=.1), ncol=40, nrow=20)
  
  ## Set new coordinates 
  coordinates(r)[,1] &lt;- as.vector(x)
  coordinates(r)[,2] &lt;- as.vector(y)
  </code></pre>
  
  <p>but this yields the error:</p>
  
  <pre><code>Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘coordinates&lt;-’ for signature ‘"RasterLayer"’
  </code></pre>
  
  <p>Is there an easy way to replace the lat longs in a raster? </p>