I have two data tables with the same dimensions- one filled with numbers, the other with symbols which can be positive or negative, ex.
A = data.table(colOne = c(-1, 3, 4),
colTwo = c(1, 0, -1));
B = data.table(colOne = c("a","b","-c"),
colTwo = c("d","-e","f"));
and need to multiply both elementwise:
resultMatrix = data.table(colOne = c("-a","3b","-4c"),
colTwo = c("d","0","-f"))
("-e*0"
would also be acceptable instead of "0"
in colTwo
of the result) and am unsure how to do this without going through loops which costs a lot of time for larger tables. What is the proper way to go about doing this?