title: Class based weighted raster aggregation
body: <p>Let's assume I have a raster representing land use classes in a certain resolution. I have to aggregate this raster with R to a coarser resolution and a modal value approach, in order to have the most dominating cell value in the coarser raster. This is easily achieved with </p>
  
  <pre><code>m &lt;- aggregate(r, fact = 3, fun = modal, na.rm = TRUE)
  </code></pre>
  
  <p>However, I would like to weight the different land use classes – e.g. forest class (code 1) has a weight of 4 while water class (code 2) has a weight of 2 and street class has a weight of 1.</p>
  
  <p>Is there a function that iterates through raster cells and applies a weight for each cell?</p>
  
  <p>Thanks for any help?</p>