title: R: Sometimes system.file not working as documented
body: <p>The <code>system.file</code> commands in my package examples sometimes fail unpredictably, while passing at other times.  I do not understand why.  </p>
  
  <p>I typically use: </p>
  
  <pre><code>&gt; system.file("examples", "trees.xml", package="RNeXML", mustWork=TRUE)
  </code></pre>
  
  <p>which usually works, but sometimes fails (even in an interactive session): </p>
  
  <pre><code>Error in system.file("examples", "trees.xml", package = "RNeXML", mustWork = TRUE) : 
  </code></pre>
  
  <p>no file found</p>
  
  <p>when it is failing, I can get this to work: </p>
  
  <pre><code>&gt; system.file("examples", "trees.xml", lib.loc = .libPaths()[1], package="RNeXML", mustWork=TRUE)
  [1] "/home/cboettig/R/x86_64-pc-linux-gnu-library/3.0/RNeXML/examples/trees.xml"
  </code></pre>
  
  <p>Which doesn't make any sense to me, because the documentation of <code>system.file</code> says that it checks <code>libPaths</code> automatically if no value for <code>lib.loc</code> is provided.  </p>
  
  <p>So why does it work if I give the <code>.libPaths()[1]</code> explicitly?</p>
  
  <p>It seems like explicitly telling my package to use the first path, <code>.libPaths()[1]</code>, would be less stable.  </p>