title: How to build a raster/raster stack to accept values based on df
body: <p>I am trying to build some data structures to accept data.</p>
  <pre><code>r1 = raster(matrix(NA,3,3)) 
  df &lt;- data.frame(a = c(1,2,3), b = c(2,2,2), val = c(10,20,30)) #example of data
  
  </code></pre>
  <p>Then I was hoping to fill this raster with values based on a df. But not like this, but based on the values of <code>df$a</code> and <code>df$b</code>.</p>
  <pre><code>plot(r1) #empty
  values(r1) &lt;- c(NA, df$val[[1]], NA, NA,df$val[[2]],NA,NA,NA,df$val[[3]]) #unindex filling
  plot(r1) #wanted result
  
  </code></pre>
  <p>I hope its clear what I am hoping to achieve. Its geolocation data, and therefore <code>df$a</code> and <code>df$b</code> will become Lon and Lat, and <code>df$val</code> will be an environmental variable. The layers will become monthly averages. Not all raster cells will have variables.</p>
  <p>Thanks.</p>