A reproducible example,
mat1 <- matrix(c(1,3,1,2,3,4), nrow = 2, ncol = 3, byrow = T) jj <- c(3:1) > mat1 [,1] [,2] [,3] [1,] 1 3 1 [2,