Finding dot product in r

Without using matrices or any special libraries:

The dot product of two vectors can be calulated by multiplying them element-wise with * then summing the result.

a <- c(1,2,3)
b <- c(4,5,6)

sum(a*b)

Leave a Comment