Code Fix

中級 › non-conformable arguments の原因と直し方(行列の次元不一致) › パターン5

non-conformable arguments の原因と直し方(行列の次元不一致)

行列の掛け算%*%は、左の行列の列数と右の行列の行数が一致していないと計算できません。

 1  u <- matrix(1:8, nrow = 2, ncol = 4)
 2  v <- matrix(1:8, nrow = 2, ncol = 4)
 3  result <- __________
                   ^
 4  cat(result, "\n")
Error in u %*% v : non-conformable arguments

空欄を埋めて実行を通す

広告
広告スロット(未設定)

non-conformable arguments の原因と直し方(行列の次元不一致)

次元が合わないとnon-conformable argumentsというエラーになります。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)