What I want to do is multiply all the values in column 1 of a data.frame by the first element in a vector, then multiply all the values in column 2 by the 2nd element in the
We can also replicate the vector to make the lengths equal and then multiply
d1*v1[col(d1)] # c1 c2 c3 #1 1 8 21 #2 2 10 24 #3 3 12 27
Or use sweep
sweep
sweep(d1, 2, v1, FUN="*")
Or with mapply to multiply the corresponding columns of 'data.frame' and elements of 'vector'
mapply
mapply(`*`, d1, v1)