I have a vector (x) that I want to multiply by a scalar. I want the entire x vector to be multiplied by each scalar value.
Here is an example of the result I want:
x <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scalar <- c(1.2, 1.4, 1.6, 1,7, 1.8, 1.9, 2.0)
x times 1.2 <- c(1.2, 2.4, 3.6, 4.8, 6, 7.2, 8.4, 9.6, 10.8, 12)
My end result should be 7 new vectors/columns that contain each element of x * 1.2, each element of x * 1.4, and so on.
I tried using the following:
for(i in seq(from=1, to=2, by=0.2))
score <- x * i
But this only multiplies x elements by 2.0.
Any suggestions on how to accomplish this are welcome.