Here's one approach:
do.call(cbind, lapply(df1, "*", as.matrix(df2)))
1 2 1 2 1 2
[1,] 0 4 0 4 0 0
[2,] 0 0 0 0 0 0
[3,] 100 4 100 4 0 0
This returns a matrix. You can use as.data.frame
to turn it into a data frame if it's necessary.
This is based on the following data:
df1 <- data.frame(A = c(1,0,1), B = c(1,0,1), C = 0)
df2 <- data.frame("1" = c(0,100,100), "2" = c(4,0,4),
check.names = FALSE)