title: Assign coordinates to raster r
body: <p>I would like to assign <code>lonlat</code>to a <code>rasterbrick</code>, <code>r</code>. <code>r</code>was read from a <code>netcdf</code> file which had <code>latlon</code> in it. However, after reading the data, the metadata looks like:</p>
  
  <pre><code>class       : RasterBrick
  dimensions  : 699, 639, 446661, 4779  (nrow, ncol, ncell, nlayers)
  resolution  : 1, 1  (x, y)
  extent      : 0.5, 639.5, 0.5, 699.5  (xmin, xmax, ymin, ymax)
  coord. ref. : NA
  
  CRS=CRS("+proj=lcc +lat_1=33 +lat_2=45 +lat_0=40 +lon_0=-97 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs") # WRF proj4")
  </code></pre>
  
  <p>I then read in the <code>latlon</code> separately into <code>R</code>:</p>
  
  <pre><code>library(ncdf4)
  
  ncname &lt;- "file.nc"
  ncfname &lt;- paste(ncname, ".nc4", sep = "")
  dname &lt;- "tmp"  # note: tmp means temperature (not temporary)
  # open a NetCDF file
  ncin &lt;- nc_open(ncfname, write = T)
  print(ncin)
  #---------
  lon &lt;- ncvar_get(ncin, "XLONG")
  nlon &lt;- dim(lon)
  head(lon)
  lat &lt;- ncvar_get(ncin, "XLAT", verbose = F)
  nlat &lt;- dim(lat)
  head(lat)
  print(c(nlon, nlat))
  
  [1] 639 699 639 699
  </code></pre>
  
  <p>You will notice that <code>nlon</code> and <code>nlat</code> has the same dimensions as <code>r</code>.
  I don't want to <code>projectRaster</code>.</p>
  
  <p>Question:</p>
  
  <p>How can I assign the imported <code>lon</code> and <code>lat</code>to <code>r</code> such that the <code>extent</code> of <code>r</code> is <code>min(lon), max(lon), min(lat), max(lat)</code>?</p>
  
  <p>I tried  <code>coordinates(dat)=c(lon,lat)</code> but it did not work.</p>
  
  <p>Thanks.</p>