Close! In this case, you can simply do
c <- a %*% b
The operator %*%
is actual matrix multiplication. For more on this consult the help page using
?`%*%`
Question
Let's say I have matrix a which is 10x10 (10 rows) and matrix b which is 10x1 (column)
and I want to multiply each row of a with b, so the end result would be a column of 10 elements.
for(i in 1:nrow(a)) a[i,] %*% b[,1]
I have something like the above right now
1) Is this correct? 2) How do I get it to display on screen?
Thank you, please keep in mind I'm a beginner with R. :)
Solution
Close! In this case, you can simply do
c <- a %*% b
The operator %*%
is actual matrix multiplication. For more on this consult the help page using
?`%*%`