Matrix Multiplication Error in R: non-conformable arguments (2 Examples) | How to Replicate & Fix

preview_player
Показать описание
R code of this video:

m1 <- matrix(2) # Create first data object
m1 # Print first data object

m2 <- matrix(1:15, nrow = 5) # Create second data object
m2 # Print second data object

m1 %*% m2 # Trying to multiply data objects

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

%*% is dot product not multiplication. The reason it doesn't work is because the dot product is not defined based on the dimensions of the two matrices, 1x1 and 5x3. Columns of left side matrix must match rows of right side matrix in equation. Solution is scalar multiplication, c * matrix. You can multiply a single value with multiple, for instance if you used the same 1x1 matrix with a 1x5 matrix the dot product is defined. - Linear Algebra

wackymints
visit shbcf.ru