Facilitates iterating over matrix, returning a sequence of pairs, where the first element is a value at index (x, y) and the second one is the index (x, y)

seq_matrix(mat)

Arguments

mat

matrix

Value

list of two-element list (single value, two-element vector)

Examples

mat <- matrix(1:9, 3, 3) seq_matrix(mat)
#> [[1]] #> [[1]][[1]] #> [1] 1 1 #> #> [[1]][[2]] #> [1] 1 #> #> #> [[2]] #> [[2]][[1]] #> [1] 1 2 #> #> [[2]][[2]] #> [1] 4 #> #> #> [[3]] #> [[3]][[1]] #> [1] 1 3 #> #> [[3]][[2]] #> [1] 7 #> #> #> [[4]] #> [[4]][[1]] #> [1] 2 1 #> #> [[4]][[2]] #> [1] 2 #> #> #> [[5]] #> [[5]][[1]] #> [1] 2 2 #> #> [[5]][[2]] #> [1] 5 #> #> #> [[6]] #> [[6]][[1]] #> [1] 2 3 #> #> [[6]][[2]] #> [1] 8 #> #> #> [[7]] #> [[7]][[1]] #> [1] 3 1 #> #> [[7]][[2]] #> [1] 3 #> #> #> [[8]] #> [[8]][[1]] #> [1] 3 2 #> #> [[8]][[2]] #> [1] 6 #> #> #> [[9]] #> [[9]][[1]] #> [1] 3 3 #> #> [[9]][[2]] #> [1] 9 #> #>