The array-function in c gives me 3 matrices in the array. I want to multiply each value in vector a with each matrix from c.
When I run this code, it seems that values are calculated in the wrong order. Some help will be much appreciated.
N <- c("P1", "P2", "D1", "D2")
a = matrix(c(16.2, 18, 21), ncol = 3)
b <- matrix(c(
0, 2721, 3109, 1943,
2721, 0, 1166, 1943,
3109, 1166, 0, 1166,
1943, 1943, 1166,0
), ncol = 4, dimnames = list(N, N))
c <- array(c(b), dim = c(4,4,3))[,,c(1:3)]* a[c(1:3)]