0

enter image description here

Why does it says NA? This is a code that shows the diagonal elements.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
신용우
  • 3
  • 1

1 Answers1

1
  • mat4[u, v] not mat4[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))