title: convert uppertriangular matrix to a symmetric matrix in R
body: <p>I have a dataframe  with 20 rows where each row is a 10 x 10 upper triangular co-variance matrix with diagonal and I want to convert it to a symmetric 10X10  matrix. I had been following the post: <a href="https://stackoverflow.com/questions/30787317/a-vector-to-an-upper-triangle-matrix-by-row-in-r">a vector to an upper Triangle matrix by row in R</a> 
  But when I do that it gives me a list instead of matrix. </p>
  
  <p>Also I want to do it recursively for each row and store the resulting 20 matrices in a list. For reproducible example here is a dataframe with 20 rows. Each row is 3x3 uppertriangular matrix with diagonal. </p>
  
  <pre><code>g &lt;- data.frame(a=runif(20),b=runif(20),c=runif(20),d=runif(20),e=runif(20),f=runif(20))
  g1&lt;-c(g[1,])
  g2= matrix(0, 3, 3)
  g2[upper.tri(g2, diag=TRUE)]=g1
  g2
  # list of 9 elements instead of matrix
  #[[1]]
   # [1] 0.2625916
  
   # [[2]]
   # [1] 0
  
   # [[3]]
   # [1] 0
  
   # [[4]]
   # [1] 0.6255627
  
   # [[5]]
   # [1] 0.829801
  
   # [[6]]
   # [1] 0
  
   # [[7]]
   # [1] 0.3386346
  
   # [[8]]
    #[1] 0.9517039
  
   # [[9]]
   # [1] 0.5886387
  </code></pre>