title: Source R into chunk
body: <p>I'm a new in <code>exams</code> so maybe this question is very newbie.</p>
  
  <p>I can't <code>source</code> external <code>R</code>-file (contains re-usable functions) into my <code>.Rnw</code>.</p>
  
  <p>MWE:</p>
  
  <p><strong>functions.r</strong>:</p>
  
  <pre><code>x &lt;- 10
  </code></pre>
  
  <p><strong>question.Rnw</strong></p>
  
  <pre><code>&lt;&lt;echo=FALSE&gt;&gt;=
  source('functions.r')
  @
  \begin{question}
    $x=\Sexpr{x}$
  \end{question}
  </code></pre>
  
  <p><strong>generate.r</strong></p>
  
  <pre><code>library('exams')
  
  exams2moodle('question.Rnw')
  </code></pre>
  
  <p>When I try <code>Rscript generate.r</code>:</p>
  
  <pre><code>Loading required namespace: rmarkdown
  
  Error:  chunk 1 
  Error in file(filename, "r", encoding = encoding) : 
    cannot open the connection
  In addition: Warning message:
  In file(filename, "r", encoding = encoding) :
    cannot open file 'functions.r': No such file or directory
  Execution halted
  </code></pre>
  
  <p>How can I re-use own R-functions in some questions?</p>