title: how to extract multiple function output automatially in R
body: <p>I have built my own function, where it returns many values. I really need to extract several values at once. For example, suppose the following is my function</p>
  <pre><code>myfunc &lt;- function(x,y){
    res &lt;- x+y
    res2 &lt;- x^2
    res3 &lt;- x*2
    
    out &lt;- list()
    out$add &lt;- res
    out$squ &lt;- res2
    out$or &lt;- res3
    out$ADD &lt;- res+res2+res3
    out$fi &lt;- res^2+res2+res3
    
    return(out)
  }
  </code></pre>
  <p>Then,</p>
  <pre><code>    &gt; myres
  $add
  [1] 7
  
  $squ
  [1] 9
  
  $or
  [1] 6
  
  $ADD
  [1] 22
  
  $fi
  [1] 64
  </code></pre>
  <p>suppose I want to extract two values at a time, for example,</p>
  <pre><code>myres$add, and myres$ADD 
  </code></pre>
  <p>is there a way to find them automatically in R instead of repeating it. My original function is very complicated and this will help a lot.</p>