I can not find a duplicate at the moment.
My problem is this:
I have two data.tables
. One with two columns (featurea, count), the other with three columns (featureb, featurec, count). I want to multiply (?), So that I have a new data.table
with all the features. The trick is that these functions do not match, so merge
decisions may not perform the trick.
MRE as follows:
# two columns DT1 <- data.table(featurea =c("type1","type2"), count = c(2,3)) # featurea count #1: type1 2 #2: type2 3 #three columns DT2 <- data.table(origin =c("house","park","park"), color =c("red","blue","red"),count =c(2,1,2)) # origin color count #1: house red 2 #2: park blue 1 #3: park red 2
My expected result in this case is data.table
as follows:
> DT3 origin color featurea total 1: house red type1 4 2: house red type2 6 3: park blue type1 2 4: park blue type2 3 5: park red type1 4 6: park red type2 6
source share