Advertisement
elena1234

Iterate through matrix

Apr 11th, 2022
907
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mat <- matrix(1:25, nrow = 5, byrow = T)
  2.  
  3. for (row in 1:nrow(mat)) {
  4.   for (col in 1:ncol(mat)) {
  5.     print(mat[row, col])
  6.   }
  7. }
  8.  
Advertisement
RAW Paste Data Copied
Advertisement