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