title: Non-conformable arguments when using apply
body: <p>I have a 10000 x 7 data.table <em>dat</em> . I would like to multiply each row of dat by a 7x7 matrix <em>c</em>. I have tried the following</p>
  
  <pre><code>apply(dat, 1, function(x) sqrt(as.matrix(x)  %*%  as.matrix(c)  %*%  t(as.matrix(x))))
  </code></pre>
  
  <p>I get this error</p>
  
  <blockquote>
    <p>Error in as.matrix(x) %*% as.matrix(c) : non-conformable arguments</p>
  </blockquote>
  
  <p>This function works when I take a single row from <em>dat</em> (so 1 x 7) but not when I use apply.</p>
  
  <p>How do I make this work using apply? </p>
  
  <p>Thanks!</p>
  
  <p>Additional info - I could achieve what I need another way. I could multiply the entire data.frame by the matrix and take <code>sqrt(diag(x))</code>. However, I need to do this a lot of times, so it would be more efficient to take this row by row and return a single figure.</p>