中級 › non-conformable arguments の原因と直し方(行列の次元不一致) › パターン1
non-conformable arguments の原因と直し方(行列の次元不一致)
行列の掛け算%*%は、左の行列の列数と右の行列の行数が一致していないと計算できません。
1 m1 <- matrix(1:6, nrow = 2, ncol = 3) 2 m2 <- matrix(1:6, nrow = 2, ncol = 3) 3 result <- ____________ ^ 4 cat(result, "\n")
Error in m1 %*% m2 : non-conformable arguments
空欄を埋めて実行を通す
m1の列数(3)とm2の行数(2)が一致していないため掛け算できません。t(m2)で転置すれば3行2列になり計算できます。
次の問題