R Matrix Multiplication -
i have list, r=
[[1]] [,1] [,2] [1,] 100 0 [2,] 0 100 [[2]] [,1] [,2] [1,] 0.0006364031 0.2521204 [2,] 0.2521204236 99.9993643` i'm suppose f %*% r
f [1,] 1 -6.264917e-04 [2,] 1 1.575666e-04 as in f[1,] matrix multiplied r[[1]], f[2,] matrix multiplied r[[2]]
how should go bout doing that?
sorry. think misunderstood. want f[1,]%*%r[[1]]%*%t(f[1,]) , f[2,]%*%r[[2]]%*%t(f[2,]) @sven hohenstein
mapply("%*%", as.data.frame(t(f)), r, simplify = false) $v1 [,1] [,2] [1,] 100 -0.06264917 $v2 [,1] [,2] [1,] 0.0006761289 0.267877 update
to answer second question:
lapply(r, function(x) f %*% x %*% t(f)) [[1]] [,1] [,2] [1,] 100.00004 99.99999 [2,] 99.99999 100.00000 [[2]] [,1] [,2] [1,] 0.0003597493 0.0005083061 [2,] 0.0005083062 0.0007183373 update
to answer updated question:
mapply(function(x, y) y %*% x %*% as.matrix(y), r, as.data.frame(t(f)), simplify = false) [[1]] [,1] [1,] 100 [[2]] [,1] [1,] 0.0007183373
Comments
Post a Comment