<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Leila,<br>
    <br>
    Here is a workaround. You can aggregate your raster first <br>
    <br>
    <i>or <- raster('file') </i># original<br>
    <i>ar <- aggregate(or, fact=2, fun='your function')</i> #
    aggregated raster<br>
    <br>
    And then use the extract function. xyFromCell() gives you the
    coordinates for each pixel in your original raster and you can use
    them to query your aggregated raster. Then you just build a new
    raster using the original one as a reference.<br>
    <br>
    <i>nr <- setValues(or, extract(ar, xyFromCell(or)))</i> # new
    raster<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 21-07-2017 11:55, Leila Schuh wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:119225694.2306012.1500630913248@mail.yahoo.com">
      <div style="color:#000; background-color:#fff;
        font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande,
        sans-serif;font-size:13px">
        <div id="yui_3_16_0_ym19_1_1500662648076_12265"><span
            id="yui_3_16_0_ym19_1_1500662648076_12266" lang="EN-US">Dear
            all,</span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12267"><span
            id="yui_3_16_0_ym19_1_1500662648076_12268" lang="EN-US"><br
              id="yui_3_16_0_ym19_1_1500662648076_12269">
          </span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12270"><span
            id="yui_3_16_0_ym19_1_1500662648076_12271" lang="EN-US">I am
            trying to run analyses on raster
            data and am stuck with a specific problem.</span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12272"><span
            id="yui_3_16_0_ym19_1_1500662648076_12273" lang="EN-US"><br
              id="yui_3_16_0_ym19_1_1500662648076_12274">
          </span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12275"><span
            id="yui_3_16_0_ym19_1_1500662648076_12276" lang="EN-US">I
            would like to create a moving window,
            which doesn’t assign individual values to all pixels
            included in the window,
            but one value for all pixels (within the window).
            Consequently, I would like to
            “paste the windows next to each other” rather than running
            calculations for
            every individual pixel.</span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12277"><span
            id="yui_3_16_0_ym19_1_1500662648076_12278" lang="EN-US"><br
              id="yui_3_16_0_ym19_1_1500662648076_12279">
          </span></div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1500662648076_12280"><span
            id="yui_3_16_0_ym19_1_1500662648076_12281" lang="EN-US">I
            haven’t figured out how to do this with
            focal or focalWeight. (I also tried to use aggregate instead
            of a moving window, but it doesn't allow me to use
            self-defined functions.) <br
              id="yui_3_16_0_ym19_1_1500662648076_12282">
          </span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12283"><span
            id="yui_3_16_0_ym19_1_1500662648076_12284" lang="EN-US"><br
              id="yui_3_16_0_ym19_1_1500662648076_12285">
          </span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12286"><span
            id="yui_3_16_0_ym19_1_1500662648076_12287" lang="EN-US">If
            anyone could help me out with this, that
            would awesome!</span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12288"><span
            id="yui_3_16_0_ym19_1_1500662648076_12289" lang="EN-US"><br
              id="yui_3_16_0_ym19_1_1500662648076_12290">
          </span></div>
        <div dir="ltr" id="yui_3_16_0_ym19_1_1500662648076_12291"><span
            id="yui_3_16_0_ym19_1_1500662648076_12292" lang="EN-US">I'll
            send a tiny bit of code and the raster file I'm working
            with.<br id="yui_3_16_0_ym19_1_1500662648076_12293">
          </span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12294"><span
            id="yui_3_16_0_ym19_1_1500662648076_12295" lang="EN-US"><br
              id="yui_3_16_0_ym19_1_1500662648076_12296">
          </span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12297"><span
            id="yui_3_16_0_ym19_1_1500662648076_12298" lang="EN-US">Thank
            you and best wishes,</span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12299"><span
            id="yui_3_16_0_ym19_1_1500662648076_12300" lang="EN-US">Leila</span></div>
        <div id="yui_3_16_0_ym19_1_1500662648076_12301">
          <div dir="ltr" id="yui_3_16_0_ym19_1_1500662648076_12304"><span
              id="yui_3_16_0_ym19_1_1500662648076_12302" lang="EN-US"><br
                id="yui_3_16_0_ym19_1_1500662648076_12303">
            </span></div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
RS-ecology mailing list
<a class="moz-txt-link-abbreviated" href="mailto:RS-ecology@lists.uni-wuerzburg.de">RS-ecology@lists.uni-wuerzburg.de</a>
<a class="moz-txt-link-freetext" href="https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology">https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>