I can't seem to get this right. I have a matrix A, and it's upper off-diagonal elements in column order
A [,1] [,2] [,3] [,4] [1,] 1 5 9 13 [2,] 2 6 10 14 [3,] 3 7 11 15 [4,] 4 8 12 16 A[col(A) > row(A)] [1] 5 9 10 13 14 15 How would I get these elements in row order? In this case: 5 9 13 10 14 15
Thank you
t(A)[lower.tri(A)]B <- t(A); B[col(B) < row(B)]seems to work.