User defined function export multiple data frames into global environment
<p>I have created a function, which computes the statistics on various patients data, and as well as outputting plots, it generates data frames containing summary statistics for each patient. </p>

<p>If i copy and run the function within R, the outputs are available to me. However, I am now calling the function from a separate R script, and the data frames are no longer available.</p>

<p>Is there any way to correct this?</p>

<p>For example, </p>

<pre><code>test=function(a){
  A=a
  B=2*a
  C=3*a
  D=4*a
  DF=data.frame(A,B,C,D)
}

a=c(1,2,3,4)
test(a)
</code></pre>

<p>This does not return <code>DF</code>, yet if I were to type:</p>

<pre><code>  a=c(1,2,3,4)
  A=a
  B=2*a
  C=3*a
  D=4*a
  DF=data.frame(A,B,C,D)
</code></pre>

<p>Then clearly <code>DF</code> is returned. Is there a simple way to fix this so that <code>DF</code> becomes available from the <code>test</code> function?</p>