1

A is a list of 8 matrices dimension 2x2, so length of A=8. How can I multiply each matrix in A with a matrix B dimension 2x2 to get a new list of 8 matrices dim2x2? A and B are already defined.

I know "lapply" may help, but I'm still stuck. Thanks for your help!

cherrykate
  • 35
  • 6

1 Answers1

4
A = list(a = matrix(1:4, 2), b = matrix(2:5, 2))
B = matrix(3:6, 2)
lapply(A, FUN = function(x) x %*% B)

I guess this is what you need, next time please provide a reproducible example.

Sean Lin
  • 805
  • 4
  • 12