Skip to content
Prev 310672 / 398506 Next

multiply each row in a matrix with the help of the for loop

Another alternative is:

aa <- array(0, dim = c(3,3,3))
a <- matrix(1, 3, )

for (i in 1:3) {
      a[i, ] <- -a[i, ]
      aa[, , i] <- a
}

aa

I hope it helps.

Best,
Dimitris