Advertisement
elena1234

Iterate through matrix

Apr 11th, 2022
1,822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.13 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment
Advertisement