title: R: Using output from one function to set all attributes of another function
body: <p>I want the output of one function to be able to set all, or possibly only the needed/given, attributes of another. I want to use the output of myFunction1() on its own, which does some calculations and based on that produces multiple needed values, or in combination with myFunction2(), which is supposed to use those values in a plot or similar. The code would look something like this:</p>
  <pre><code>myFunction1() &gt;%&gt; myFunction2()
  </code></pre>
  <p>I'm aware that I can possibly put the function that needs the output inside the first function, like:</p>
  <pre><code>myFunction1=function(x, logical){
   x=x^2
   y=&quot;&quot;
  if(x&gt;100){
   y=&quot;hello&quot;
  }else{
   y=&quot;goodbye&quot;
   }
  if(logical){
   return(list(x=x,y=y,logical=logical))
  }else{
   return(myFunction2(x,y,logical))
   }
  } ##end myFunction1()
  
  myFunction2=function(x, y, z){
  a=paste0(x, y, z)
  return(a)
  }
  </code></pre>
  <p>or use the output with the $-operator</p>
  <pre><code>myOutput = myFunction(1, TRUE)
  myOutput2 = myFunction2(myOutput$x, myOutput$y, myOutput$logical)
  </code></pre>
  <p>But is there a way to have a list output (or anything that can contain different data types) be able to set all attributes without the need of addressing the output via $ or index?</p>
  <p>(First post so feedback regarding the wrongs would be appreciated aswell)</p>