EVOLUTION-MANAGER
Edit File: load_all.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Load complete package</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for load_all {pkgload}"><tr><td>load_all {pkgload}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Load complete package</h2> <h3>Description</h3> <p><code>load_all()</code> loads a package. It roughly simulates what happens when a package is installed and loaded with <code><a href="../../base/html/library.html">library()</a></code>, without having to first install the package. It: </p> <ul> <li><p> Loads all data files in <code style="white-space: pre;">data/</code>. See <code><a href="load_data.html">load_data()</a></code> for more details. </p> </li> <li><p> Sources all R files in the R directory, storing results in environment that behaves like a regular package namespace. See <code><a href="load_code.html">load_code()</a></code> for more details. </p> </li> <li><p> Adds a shim from <code><a href="system.file.html">system.file()</a></code> to <code><a href="system.file.html">shim_system.file()</a></code> in the imports environment of the package. This ensures that <code>system.file()</code> works with both development and installed packages despite their differing directory structures. </p> </li> <li><p> Adds shims from <code>help()</code> and <code style="white-space: pre;">?</code> to <code><a href="help.html">shim_help()</a></code> and <code><a href="help.html">shim_question()</a></code> to make it easier to preview development documentation. </p> </li> <li><p> Compiles any C, C++, or Fortran code in the <code style="white-space: pre;">src/</code> directory and connects the generated DLL into R. See <code><a href="../../pkgbuild/html/compile_dll.html">pkgbuild::compile_dll()</a></code> for more details. </p> </li> <li><p> Loads any compiled translations in <code>inst/po</code>. </p> </li> <li><p> Runs <code>.onAttach()</code>, <code>.onLoad()</code> and <code>.onUnload()</code> functions at the correct times. </p> </li> <li><p> If you use <span class="pkg">testthat</span>, will load all test helpers so you can access them interactively. devtools sets the <code>DEVTOOLS_LOAD</code> environment variable to <code>"true"</code> to let you check whether the helpers are run during package loading. </p> </li></ul> <p><code>is_loading()</code> returns <code>TRUE</code> when it is called while <code>load_all()</code> is running. This may be useful e.g. in <code>.onLoad</code> hooks. </p> <h3>Usage</h3> <pre> load_all( path = ".", reset = TRUE, compile = NA, attach = TRUE, export_all = TRUE, export_imports = export_all, helpers = TRUE, attach_testthat = uses_testthat(path), quiet = NULL, recompile = FALSE, warn_conflicts = TRUE ) is_loading(pkg = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>path</code></td> <td> <p>Path to a package, or within a package.</p> </td></tr> <tr valign="top"><td><code>reset</code></td> <td> <p>clear package environment and reset file cache before loading any pieces of the package. This largely equivalent to running <code><a href="unload.html">unload()</a></code>, however the old namespaces are not completely removed and no <code>.onUnload()</code> hooks are called. Use <code>reset = FALSE</code> may be faster for large code bases, but is a significantly less accurate approximation.</p> </td></tr> <tr valign="top"><td><code>compile</code></td> <td> <p>If <code>TRUE</code> always recompiles the package; if <code>NA</code> recompiles if needed (as determined by <code><a href="../../pkgbuild/html/needs_compile.html">pkgbuild::needs_compile()</a></code>); if <code>FALSE</code>, never recompiles.</p> </td></tr> <tr valign="top"><td><code>attach</code></td> <td> <p>Whether to attach a package environment to the search path. If <code>FALSE</code> <code>load_all()</code> behaves like <code>loadNamespace()</code>. If <code>TRUE</code> (the default), it behaves like <code>library()</code>. If <code>FALSE</code>, the <code>export_all</code>, <code>export_imports</code>, and <code>helpers</code> arguments have no effect.</p> </td></tr> <tr valign="top"><td><code>export_all</code></td> <td> <p>If <code>TRUE</code> (the default), export all objects. If <code>FALSE</code>, export only the objects that are listed as exports in the NAMESPACE file.</p> </td></tr> <tr valign="top"><td><code>export_imports</code></td> <td> <p>If <code>TRUE</code> (the default), export all objects that are imported by the package. If <code>FALSE</code> export only objects defined in the package.</p> </td></tr> <tr valign="top"><td><code>helpers</code></td> <td> <p>if <code>TRUE</code> loads <span class="pkg">testthat</span> test helpers.</p> </td></tr> <tr valign="top"><td><code>attach_testthat</code></td> <td> <p>If <code>TRUE</code>, attach <span class="pkg">testthat</span> to the search path, which more closely mimics the environment within test files.</p> </td></tr> <tr valign="top"><td><code>quiet</code></td> <td> <p>if <code>TRUE</code> suppresses output from this function.</p> </td></tr> <tr valign="top"><td><code>recompile</code></td> <td> <p>DEPRECATED. force a recompile of DLL from source code, if present. This is equivalent to running <code><a href="../../pkgbuild/html/clean_dll.html">pkgbuild::clean_dll()</a></code> before <code>load_all()</code></p> </td></tr> <tr valign="top"><td><code>warn_conflicts</code></td> <td> <p>If <code>TRUE</code>, issues a warning if a function in the global environment masks a function in the package. This can happen when you accidentally source a <code>.R</code> file, rather than using <code>load_all()</code>, or if you define a function directly in the R console. This is frustrating to debug, as it feels like the changes you make to the package source aren't having the expected effect.</p> </td></tr> <tr valign="top"><td><code>pkg</code></td> <td> <p>If supplied, <code>is_loading()</code> only returns <code>TRUE</code> if the package being loaded is <code>pkg</code>.</p> </td></tr> </table> <h3>Differences to regular loading</h3> <p><code>load_all()</code> tries its best to reproduce the behaviour of <code><a href="../../base/html/ns-load.html">loadNamespace()</a></code> and <code><a href="../../base/html/library.html">library()</a></code>. However it deviates from normal package loading in several ways. </p> <ul> <li> <p><code>load_all()</code> doesn't install the package to a library, so <code><a href="system.file.html">system.file()</a></code> doesn't work. pkgload fixes this for the package itself installing a shim, <code><a href="system.file.html">shim_system.file()</a></code>. However, this shim is not visible to third party packages, so they will fail if they attempt to find files within your package. One potential workaround is to use <code><a href="../../fs/html/path_package.html">fs::path_package()</a></code> instead of <code>system.file()</code>, since that understands the mechanisms that devtools uses to load packages. </p> </li> <li> <p><code>load_all()</code> loads all packages referenced in <code>Imports</code> at load time, but <code>loadNamespace()</code> and <code>library()</code> only load package dependencies as they are needed. </p> </li> <li> <p><code>load_all()</code> copies all objects (not just the ones listed as exports) into the package environment. This is useful during development because it makes internal objects easy to access. To export only the objects listed as exports, use <code>export_all = FALSE</code>. This more closely simulates behavior when loading an installed package with <code><a href="../../base/html/library.html">library()</a></code>, and can be useful for checking for missing exports. </p> </li></ul> <h3>Examples</h3> <pre> ## Not run: # Load the package in the current directory load_all("./") # Running again loads changed files load_all("./") # With reset=TRUE, unload and reload the package for a clean start load_all("./", TRUE) # With export_all=FALSE, only objects listed as exports in NAMESPACE # are exported load_all("./", export_all = FALSE) ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>pkgload</em> version 1.3.1 <a href="00Index.html">Index</a>]</div> </body></html>