title: Generate covariance matrix from correlation matrix
body: <p>I have a correlation matrix:</p>
  
  <pre><code>a &lt;- matrix(c(1, .8, .8, .8, 1, .8, .8, .8, 1), 3)
  
  ##      [,1] [,2] [,3]
  ## [1,]  1.0  0.8  0.8
  ## [2,]  0.8  1.0  0.8
  ## [3,]  0.8  0.8  1.0
  </code></pre>
  
  <p>I would now like to create a covariance matrix from the correlation matrix. How can this be done in R?</p>
  
  <p>I tried:</p>
  
  <pre><code>e1.sd &lt;- 3
  e2.sd &lt;- 10
  e3.sd &lt;- 3
  e.cov &lt;- a * as.matrix(c, e1.sd, e2.sd, e3.sd) %*% t(as.matrix(c(e1.sd, e2.sd, e3.sd)))
  </code></pre>
  
  <p>But I get the error:</p>
  
  <pre><code>Error in a * as.matrix(c, e1.sd, e2.sd, e3.sd) %*% t(as.matrix(c(e1.sd,  : 
    non-conformable arrays
  </code></pre>
  
  <p>What am I doing wrong?</p>