</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"><li>
<a href="../reference/index.html">Reference</a>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul><ul class="nav navbar-nav navbar-right"></ul></div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Reshape from wide to long and save to GDX
Create sample farms</h1>
<div class="hidden name"><code>updateFarmData.Rd</code></div>
</div>
<div class="ref-description">
<p>`updateFarmData()` creates sample farms by aggregating data based on the weighted mean and the selected mapping for use in FarmDyn.
For non-numerical globals, it summarises based on the mode using the `Modes()` function. When `writegdx` is `TRUE`, it writes the GDX in the format 'farmData_(mapping).gdx'.</p>
<p>`updateFarmData()` creates sample farms by aggregating data based on the weighted mean and the selected mapping for use in FarmDyn.
For non-numerical globals, it summarises based on the mode using the `Modes()` function. When `writegdx` is `TRUE`, it writes the GDX in the format 'farmData_(mapping).gdx'.</p>
</div>
<div id="ref-usage">
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">updateFarmData</span><span class="op">(</span></span>
<span> <span class="va">filename</span>,</span>
<span> <span class="va">BINDir</span>,</span>
<span> <span class="va">gdxmap</span>,</span>
<span> <span class="va">mapping</span>,</span>
<span> writegdx <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span> cptcoeffs <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span> farmchars <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> cptcoeffsxl <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span>
<span></span>
<span><span class="fu">updateFarmData</span><span class="op">(</span></span>
<span> <span class="va">filename</span>,</span>
<span> <span class="va">BINDir</span>,</span>
<span> <span class="va">gdxmap</span>,</span>
<span> <span class="va">mapping</span>,</span>
<span> writegdx <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span> cptcoeffs <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span> farmchars <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span> cptcoeffsxl <span class="op">=</span> <span class="cn">NULL</span></span>
<span><span class="op">)</span></span></code></pre></div>
</div>
<div id="arguments">
<h2>Arguments</h2>
<dl><dt>filename</dt>
<dd><p>Name of the GDX file with BIN data and mappings.</p></dd>
<dt>BINDir</dt>
<dd><p>Directory where the FADN data is located.</p></dd>
<dt>gdxmap</dt>
<dd><p>Name of the set in the GDX file that contains the mapping (e.g. Regs2BINID)</p></dd>
<dt>mapping</dt>
<dd><p>Column name of the characteristic/variable to be grouped by (e.g. "Regions" or "Regs")</p></dd>
<dt>writegdx</dt>
<dd><p>Logical. If `TRUE`, it writes a GDX with the descriptive statistics.</p></dd>
<dt>cptcoeffs</dt>
<dd><p>Logical. When this is set to `TRUE` it calculates farm-specific parameters based on CPT coefficients</p></dd>
<dt>farmchars</dt>
<dd><p>GDX file containing farm characteristics</p></dd>
<dt>cptcoeffsxl</dt>
<dd><p>Location of the CPT coefficients excel file</p></dd>
</dl></div>
<div id="value">
<h2>Value</h2>
<p>A tibble `tbl_df`.</p>
<p>A tibble `tbl_df`.</p>
</div>
<div id="see-also">
<h2>See also</h2>
<div class="dont-index">
<ul><li><p><code><a href="gdxbinwider.html">gdxbinwider</a></code>Widens BIN data directly from GDX</p></li>
<li><p><code><a href="gdxreshape.html">gdxreshape</a></code>Lengthens data and saves to GDX</p></li>
<li><p><code><a href="https://rdrr.io/pkg/gdxrrw/man/wgdx.html" class="external-link">wgdx</a></code>Write R data to GDX</p></li>
<li><p><code><a href="https://rdrr.io/pkg/gdxrrw/man/wgdx.html" class="external-link">wgdx.lst</a></code>Write multiple symbols to GDX</p></li>
<li><p><code><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise</a></code>Make dataframes longer</p></li>
<li><p><code>weighted.mean]</code>Calculates weighted mean</p></li>
</ul><ul><li><p><code><a href="gdxbinwider.html">gdxbinwider</a></code>Widens BIN data directly from GDX</p></li>
<li><p><code><a href="gdxreshape.html">gdxreshape</a></code>Lengthens data and saves to GDX</p></li>
<li><p><code><a href="https://rdrr.io/pkg/gdxrrw/man/wgdx.html" class="external-link">wgdx</a></code>Write R data to GDX</p></li>
<li><p><code><a href="https://rdrr.io/pkg/gdxrrw/man/wgdx.html" class="external-link">wgdx.lst</a></code>Write multiple symbols to GDX</p></li>
<li><p><code><a href="https://dplyr.tidyverse.org/reference/summarise.html" class="external-link">summarise</a></code>Make dataframes longer</p></li>
<li><p><code>weighted.mean]</code>Calculates weighted mean</p></li>
</ul></div>
</div>
<div id="ref-examples">
<h2>Examples</h2>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top"><h2 data-toc-skip>Contents</h2>
</nav></div>
</div>
<footer><div class="copyright">
<p></p><p>Developed by Hugo Scherer.</p>
</div>
<div class="pkgdown">
<p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.7.</p>
</div>
</footer></div>
</body></html>