title: When I know the class of an R object, can I call the appropriate method directly?
body: <p>Consider a simple R function:</p>
  <pre class="lang-r prettyprint-override"><code>#' @importFrom BarPackage Bar
  Foo &lt;- function (n, x) {
    replicate(1e6, Bar(numeric(n), x))
  }
  </code></pre>
  <p>If <code>Bar()</code> is a method, then calling <code>Bar.numeric(numeric(n), x)</code> saves R from having to look up the class of <code>numeric(n)</code>; in a real-world example, this shaves about 10% off my run time.</p>
  <p>However, <code>Bar.numeric()</code> is a function in a separate package (which I maintain).  Roxygen creates <code>export(Bar)</code> and <code>S3method(Bar, numeric)</code> entries in NAMESPACE, but if I add <code>importFrom BarPackage Bar</code> to the FooPackage NAMESPACE and try to run <code>Foo()</code>, I see <code>Warning message: 'Bar.numeric' is not exported by 'namespace:BarPackage'</code> -- as indeed it's not.</p>
  <p>It feels like I need to create a separate entry in my NAMESPACE reading <code>export(Bar.numeric)</code>, but this feels like a very bad idea (in part because I don't think that Roxygen will do it).  Is there any other way of avoiding R having to look up the class of <code>numeric(n)</code> on each call to <code>Bar()</code>?</p>