matcomb.rd
create matrix indices from row and columns positions
matcomb(r, c)
integer vector of row positions
integer vector of column positions
rows rotate faster than columns
a k by 2 matrix of matrix indices where k = length(r) * length(c)
k = length(r) * length(c)
Jens Oehlschlägel
row, col , expand.grid
row
col
expand.grid
matcomb(1:3, 1:4) #> r c #> [1,] 1 1 #> [2,] 2 1 #> [3,] 3 1 #> [4,] 1 2 #> [5,] 2 2 #> [6,] 3 2 #> [7,] 1 3 #> [8,] 2 3 #> [9,] 3 3 #> [10,] 1 4 #> [11,] 2 4 #> [12,] 3 4 matcomb(2:3, 2:4) #> r c #> [1,] 2 2 #> [2,] 3 2 #> [3,] 2 3 #> [4,] 3 3 #> [5,] 2 4 #> [6,] 3 4