Consider the following:
data(cars)
library(data.table)
A <- data.table(cars)
B <- data.table(speed = 10, dist = 100)
I would like to divide the first column of A by the first element in B and the second column of A by the second element in B. So: A[,1]/B[,1] , A[,2]/B[,2], ... The output should look like:
speed dist
1: 0.4 0.02
2: 0.4 0.10
3: 0.7 0.04
4: 0.7 0.22
...
(This is a toy example. I'm hoping to turn it into a function I can run over different datasets.)