title: package development: setting options before dependencies load
body: <p>My R package has a dependency that needs a certain option set before it loads. Setting this option in the <code>.onLoad</code> function of the <strong>zzz.r</strong> file of my package does not work, since the dependency appears to load before <code>.onLoad</code> is called.</p>
  
  <p>How can I guarantee that a certain option is set for the user of my package before its dependencies load?</p>
  
  <p>Here is a link to a sample package that illustrates the situation: <a href="https://www.dropbox.com/s/n8trcfz5scr60fk/soExample.zip?dl=0" rel="nofollow">soExample.zip</a></p>
  
  <p>The dependency in my example is the <strong>bartMachine</strong> package. The setting in question controls the amount of memory available to Java. When I'm using <strong>bartMachine</strong> in interactive mode, I can simply set the option, load <strong>bartMachine</strong>, and the startup message informs me that it has recognized the <code>java.parameters</code> option I've set and made the requested amount of memory available to Java.</p>
  
  <pre><code>options(java.parameters='-Xmx5g')
  library(bartMachine)
  # ....
  # Welcome to bartMachine v1.2.1! You have 4.77GB memory available.
  </code></pre>
  
  <p>However, when I load my package that depends on <strong>bartMachine</strong>, the <code>java.parameter</code> option set in <code>.onLoad</code> does not take effect in time and <strong>bartMachine</strong> makes only the default amount of memory available.</p>
  
  <pre><code>library(soExample)
  # ....
  # Welcome to bartMachine v1.2.1! You have 0.48GB memory available.
  </code></pre>