I have a question regarding adding a column to a data.table
based on info in another data.table
.
This is how my data looks:
dt.1: One column with 1.9 million Product ID's
0771044445
0827229534
0827229534
0738700797
etc.
dt.2: Two columns with 7 million Product ID's + Categories
0842328327 Book
0842328327 Book
1577943082 DVD
Etc.
Now I want to create a column in dt.1
which adds the category by looking up this category in dt.2
. All ID's of dt.1
are in dt.2
.
I tried:
dt.1[,group := ID %in% dt.2, by = dt.2$category]
But I get the following error:
Error in `[.data.frame`(dt.amazon.similar, , `:=`(group, asin %in% dt.amazon.reviews), : unused argument (by = dt.amazon.reviews$group)