I am trying to assign whether 6 character product codes are canadian or United states products.
The desired output is all codes starting with D (and not ending in S or C) or C are classified as "CAN" while all else are "USA".
This is likely something simple, but I am a bit rusty on my R skills here.
INV <- INV %>% mutate(COUNTRY = ifelse((substr(StyleFull,1,1)=="D" & !((substr(StyleFull,6,6)=="S")|(substr(StyleFull,6,6)="C")))|substr(StyleFull,1,1)=="C", "CAN", "USA"))
unique(INV$COUNTRY)
Aucun commentaire:
Enregistrer un commentaire