title: do.call in r with matrix and lists
body: <p>in language R, in order to generate a new matrix (N*6) as from an older one (N*3), is there a better way than the next one to do it without having to "unpack/unlist" the inner lists created in the apply function in order to "expand" the source matrix?</p>
  
  <pre><code>transformed &lt;- matrix(byrow=T)
  transformed &lt;- as.matrix(
      do.call("rbind", as.list(
        apply(dataset, 1, function(x) {
           x &lt;- list(x[1], x[2], x[3], x[2]*x[3], x[2]^2, x[3]^2)
        })
      ))
  ) 
  
  #Unpack all inner lists from the expanded matrix
  ret_trans &lt;- as.matrix( apply(transformed, 2, function(x) unlist(x)) )
  </code></pre>
  
  <p>EDIT: I add an example of that</p>
  
  <pre><code>    dataset
       [,1] [,2] [,3]
  [1,]    1    6   11
  [2,]    2    7   12
  [3,]    3    8   13
  [4,]    4    9   14
  [5,]    5   10   15
  </code></pre>
  
  <p>and on applying the code above I want to expand to N*6, 5*6 (sorry, I misspelled the column dimension up there, and the margin of apply function) it should be like that</p>
  
  <pre><code>transformed
       [,1] [,2] [,3] [,4] [,5] [,6]
  [1,] 1    6    11   66   36   121 
  [2,] 2    7    12   84   49   144 
  [3,] 3    8    13   104  64   169 
  [4,] 4    9    14   126  81   196 
  [5,] 5    10   15   150  100  225 
  </code></pre>
  
  <p>The question is if there is another way of doing that without having to use the last apply function, without having to coerce the x to be a list
  thanks all for your replies</p>