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