I need to generate lower triangle matrix indices (row and columns pairs). The current implementation is inefficient (memory wise) specially when symmetric matrix gets big (more than 50K rows). Is there a better way?
rows <- 2e+01
id <- which(lower.tri(matrix(, rows, rows)) == TRUE, arr.ind=T)
head(id)
# row col
# [1,] 2 1
# [2,] 3 1
# [3,] 4 1
# [4,] 5 1
# [5,] 6 1
# [6,] 7 1
Here's another approach:
Benchmarks with larger data: