title: Aggregating fine resolution raster to coarser resolution such that pixel value of coarse pixel is proportion of unique pixel value in fine res raster
body: <p>I have a raster with pixel values 1 or NA (first image below) with specifications includedr after image. I want to coarsen to 10km*10km resolution such that the new pixel value in the final coarse pixel is proportion of pixels with value=1 (last image below).</p>
  <p><a href="https://i.stack.imgur.com/Li7yD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Li7yD.png" alt="enter image description here" /></a></p>
  <pre><code>raster1
  class       : SpatRaster 
  dimensions  : 33301, 32538, 1  (nrow, ncol, nlyr)
  resolution  : 100, 100  (x, y)
  extent      : 7590450, 10844250, 902100, 4232200  (xmin, xmax, ymin, ymax)
  coord. ref. : WGS 84 / Pseudo-Mercator (EPSG:3857) 
  source      : spat_PDvNPPxCooNIh09_2584.tif 
  name        : pred 
  min value   :    1 
  max value   :    1 
  
  </code></pre>
  <p>How would I do this in R? I primarily use terra R package. Thank you!</p>