Here is an example taken from the Help text of the which() function. In the first call to which(), the positions of the TRUE results in the matrix are returned as integers, treating the matrix as if it were a vector. In the second call to which(), the positions of the TRUE results are returned as row and column indices stored in a matrix.
( m <- matrix(1:12, 3, 4) )
#> [,1] [,2] [,3] [,4]
#> [1,] 1 4 7 10
#> [2,] 2 5 8 11
#> [3,] 3 6 9 12
div.3 <- m %% 3 == 0
which(div.3)
#> [1] 3 6 9 12
which(div.3, arr.ind = TRUE)
#> row col
#> [1,] 3 1
#> [2,] 3 2
#> [3,] 3 3
#> [4,] 3 4
Created on 2021-01-15 by the reprex package (v0.3.0)