title: correlation-covariance matrix to variance-covariance matrix
body: <p>Is there an easy way to convert a correlation-covariance matrix into a variance-covariance matrix?  I always use nested <code>for-loops</code> as below, but I keep thinking there is probably a built-in function in base <code>R</code>.</p>
  
  <pre><code>my.matrix &lt;- matrix(c(0.64901,  0.76519, -0.63620, -0.01923,
                        0.02114,  0.00118, -0.43198,  0.02480,
                       -0.21811, -0.00630,  0.18109,  0.05964,
                       -0.00710,  0.00039,  0.01162,  0.20972), nrow=4, byrow=TRUE)
  
  new.matrix &lt;- my.matrix
  
  for(i in 1:nrow(my.matrix)) {  
     for(j in 1:ncol(my.matrix)) { 
        new.matrix[i,j] = ifelse(i&lt;j, my.matrix[j,i], new.matrix[i,j])
     }
  }
  
  new.matrix
  
  #          [,1]     [,2]     [,3]     [,4]
  # [1,]  0.64901  0.02114 -0.21811 -0.00710
  # [2,]  0.02114  0.00118 -0.00630  0.00039
  # [3,] -0.21811 -0.00630  0.18109  0.01162
  # [4,] -0.00710  0.00039  0.01162  0.20972
  </code></pre>
  
  <p>I am aware of the <code>lower.tri</code> and <code>upper.tri</code> functions, but cannot seem to accomplish the task with a combination of them and <code>t()</code>.</p>