title: How to fill in a matrix given diagonal and off-diagonal elements in r?
body: <p>I have the elements for a matrix as follows:</p>
  
  <pre><code>diag= rep(1,5)
  offdiag = c(rep(1:4), rep(1:3), rep(1:2), 1)
  </code></pre>
  
  <p>The final matrix I want should should be a symmetric matrix that looks like this:</p>
  
  <pre><code>1 1 2 3 4
  1 1 1 2 3 
  2 1 1 1 2
  3 2 1 1 1
  4 3 2 1 1
  </code></pre>
  
  <p>where the diagonal is filled by diag and the lower-trianglar area is filled by offdiag column-wise. </p>
  
  <p>In practice, all all numbers are random. So I need a generic way to fill in the matrix with elements. </p>
  
  <p>Thanks in advance!</p>