I have a main data frame containing products info such as ID, description and category (and many other variables).
main.df <- structure(list(product.ID = 1:10, 
description = c("abc...", "bcd...", "def...", "efg...", "fgh...", 
"ghi...", "hij...", "ijk...", "jkl...", "klm..."), 
category = c("a", "b", "c", "d", "e", "a", "b", "c", "d", "e")),
 .Names = c("product.ID", "description", "category"), 
 row.names = c(NA, -10L), class = "data.frame")
Then, I have a second data frame which lists the class of product each specific category belong to:
classes.df <- structure(list(category = c("a", "b", "c", "d", "e"), 
classe = c("aaa", "bbb", "aaa", "ccc", "bbb")), 
.Names = c("category", "classe"), 
row.names = c(NA, -5L), 
class = "data.frame")
The "category" variables is what 'links' the 2 data frames.
I need to add a variable in the main.df to mention the class of product each row belongs to, but I don't know how to.
Considering that my actual main.df is 4.5 millions rows spread over 90,000+ categories and my actual classes.df has the 90,000+ rows corresponding to 120 classes, how can I do that. Thank you.
main.df structure is
Classes ‘data.table’ and 'data.frame':  250000 obs. of  16 variables:
 $ ID         : int  4722 6988 9184 13224 13511 15938 19244 21162 23294 23793 ...
 $ dataset    : Factor w/ 2 levels "BA", "RB",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ prodID     : num  429 429 429 429 429 429 429 429 429 429 ...
 $ ProdName   : chr  "aaa" "aaa" "bbb" "ccc" "eee" ...
 $ manufacID  : num  1 1 1 1 1 1 1 1 1 1 ...
 $ time       : num  1271636264 1062977828 1218368958 1305424000 1284596323 ...
 $ serial     : chr  "BA1" "BA1" "RB1" "RB7" ...
 - attr(*, "sorted")= chr "serial"
 - attr(*, ".internal.selfref")=<externalptr> 
classes.df structure is:
 Classes ‘data.table’ and 'data.frame': 20565 obs. of  5 variables:
   $ ID         : int  652 1204 1252 1379 2334 2335 2336 2337 3186 3187 ...
   $ mName   : chr  "XYZ" "EHD" "DLK" "TSH" ...
   $ country: chr  "Argentina" "USA" "UK" "Argentina" ...
   $ serial : chr  "RB7" "BA1" "RB97" "RB732" ...
   - attr(*, ".internal.selfref")=<externalptr>
(for confidentiality reasons, I had to anonymise the names)
 
     
    