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