Why does it says NA? This is a code that shows the diagonal elements.
Asked
Active
Viewed 31 times
0
-
1Related post https://stackoverflow.com/q/1169456/680068 – zx8754 Apr 10 '22 at 08:56
1 Answers
1
mat4[u, v]
notmat4[u][v]
(see below)- instead of using nested loops to print the diagonal, you can use
diag(mat4)
some_matrix[u][v]
indexes first the uth element of some_matrix
(walking row-by-row, column-by-column), returning an atomic vector of length one, of which it then tries to extract the vth element (which is NA for v > 1). some_matrix[u, v]
instead indexes the matrix element in row u, column v.
please don't provide data as image files but paste the output of dput
(e.g.dput(mat4)
)