title: Create a raster with cell values from points spatially located in the same cell
body: <p>I'd like to create a raster of 480*480 resolution. The cell value should be the mean intensity value of all points falling inside the same cell. For example, the first point (138.42133 457.4437) should go to cell (139, 458) because of round up. If no other points located in the same cell, the cell value is then 160, otherwise the mean.</p>
  <p>I have thousands of points that have XY and intensity values as the sample below (sorry I don't know how to share the entire data here...). I think this could be done easily in ArcMap using spatial join but how could it be done in R? Thanks a lot.</p>
  <pre><code>&gt; sample
            imx      imy Intensity
  1   138.42133 457.4437       160
  2   131.22405 453.9341       133
  3   115.80057 445.3643         4
  4   122.90073 449.4941        33
  5   129.89724 453.2543         3
  6   145.50787 425.8380        90
  7   143.82309 459.8863        43
  8   156.35612 439.8159        13
  9   152.25119 463.3834        42
  10  159.86740 466.2272        61
  </code></pre>