title: R- multiple returns in function to create a plot
body: <p>I would like to write a function that creates a plot of a set of numbers and adds a regression line. As of now, I can still create the plot but I either get an error with the plot, or some sort of Null response.</p>
  
  <p>My function without a regression line that returns no null looks like this:</p>
  
  <pre><code>fun&lt;-function(){
  +   x&lt;-c(1,2,3,4,5)
  +   y&lt;-c(1,2,3,4,5)
  +   LR&lt;-lm(x~y)
  +   
  +   return(plot(x,y))
  + }
  &gt; fun()
  </code></pre>
  
  <p>Nice and Pretty with just a plot as a result</p>
  
  <p>if I add the regression line to the plot, I still get the plot but I also get a null response</p>
  
  <pre><code>&gt; fun&lt;-function(){
  +   x&lt;-c(1,2,3,4,5)
  +   y&lt;-c(1,2,3,4,5)
  +   LR&lt;-lm(x~y)
  +   p&lt;-plot(x,y)
  +   a&lt;-abline(LR)
  +   return(p)
  + }
  &gt; fun()
  NULL
  </code></pre>
  
  <p>or an error</p>
  
  <pre><code>&gt; fun&lt;-function(){
  +   x&lt;-c(1,2,3,4,5)
  +   y&lt;-c(1,2,3,4,5)
  +   
  +   LR&lt;-lm(x~y)
  +   
  +   p&lt;-plot(x,y)
  +   a&lt;-abline(LR)
  +   
  +   return(p,a)
  + }
  &gt; fun()
  Error in return(p, a) : multi-argument returns are not permitted
  </code></pre>
  
  <p>or two nulls</p>
  
  <pre><code>&gt; fun&lt;-function(){
  +   x&lt;-c(1,2,3,4,5)
  +   y&lt;-c(1,2,3,4,5)
  +   
  +   LR&lt;-lm(x~y)
  +   
  +   p&lt;-plot(x,y)
  +   a&lt;-abline(LR)
  +   
  +   return(list(p,a))
  + }
  &gt; fun()
  [[1]]
  NULL
  
  [[2]]
  NULL
  </code></pre>
  
  <p>Sorry if this seems ridiculously nit picky, but in the actual data set it can get ugly. </p>