create matrix indices from row and columns positions

matcomb(r, c)

Arguments

r

integer vector of row positions

c

integer vector of column positions

Details

rows rotate faster than columns

Value

a k by 2 matrix of matrix indices where k = length(r) * length(c)

Author

Jens Oehlschlägel

See also

Examples

  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