title: R Roxygen: Did not find imported function in example
body: <p>In a function of a package I'm writing, I want to create a cox ph model from the formula and data. Nothing spectacular, and the function works as intended. Internally, I call the <code>coxph</code> function, which in turn calls the <code>Surv</code> function (both from the survival package).</p>
  <p>When adding an example to the roxygen header, I get the following error message upon testing:</p>
  <blockquote>
  <p>Error in Surv(time, status) : could not find function &quot;Surv&quot;</p>
  </blockquote>
  <p>In the roxygen header, I have declared the import (went with the functions only but also tried the entire package), and the NAMESPACE file clearly lists the import. When loading the package to a clean workspace (without survival loaded), the function also works (and doesn't if I remove the import).</p>
  <p>How can I ensure that the example has the correct namespace available? I'd hate to use <code>\dontrun</code>.</p>
  <p>Abbreviated function (not intended to run, not syntactically correct, just a simplified version of what's happening for context):</p>
  <pre><code>#' @importFrom survival coxph Surv
  build_cox_model &lt;- function(params) {
  cox_form &lt;- basecamb::build_model_formula(params)
  cox_model &lt;- survival::coxph(data, cox_form)
  }
  </code></pre>
  <p>Extended error message:</p>
  <pre><code>data &lt;- survival::lung
  build_cox_model(data, 'time', 'status', c('age','sex'))
  Error in Surv(time, status) : could not find function &quot;Surv&quot;
  Calls: build_cox_model ... eval -&gt; &lt;Anonymous&gt; -&gt; model.frame.default -&gt; eval -&gt; eval
  Execution halted
  </code></pre>