Here’s another example with a code that doesn’t use dependencies (only based on R).
In its example, 456 is the same code used for YELLOW and BROWN. I created another code (457 for BROWN) to avoid duplicates (but I don’t know if that was your intention).
First I define the rule to complete the missing data with a "match" of df1 Nas that might be present in df2. And then I apply the rule about the data.frame df1
df1 <- data.frame(ITEM = c(123,456,789,234,345,457,567,678),
CLASS = c("AZUL","AMARELO",NA,"VERDE","PRETO",NA,NA,"ROSA"),
stringsAsFactors = FALSE)
df2 <- data.frame(ITEM = c(457, 567,100,200, 789),
CLASS = c("MARROM","BRANCO","CASA","BOLA","LARANJA"),
stringsAsFactors = FALSE)
r <- match(df1[is.na(df1$CLASS), "ITEM"], df2$ITEM)
df1[is.na(df1$CLASS), "CLASS" ] <- df2[r, "CLASS"]
print(df1)
ITEM CLASS
1 123 AZUL
2 456 AMARELO
3 789 LARANJA
4 234 VERDE
5 345 PRETO
6 457 MARROM
7 567 BRANCO
8 678 ROSA