I have been trying to create a vector or a matrix with a loop, but instead, it just creates a variable with the value of the last loop.
I have a 100x2 tableX and a 10x2 tableY. I need to multiply each row from table1 by rows in table2 and store the results in a matrix. (X[1,1]*Y[1,1]+X[1,2]*Y[1,2] and so on)
So in the end I need a 100x10 matrix that would contain the multiplications.
I manage to create the following loop just for the first row from tableY, so it prints the first vector of the resulting table that I need.
for (i in seq(1,100))) {
results <- ((tableX[i,1]* tableY[1,1])+(tableX[i,2]* tableY[1,2]))
print(results)
}
My question is, how do I store this printout as a vector, and then do the same of other rows of tableY?
Thank you in advance!