Ifelse with multiple conditional values

I am trying to categorize these part numbers as "roll" otherwise "sheet"
This code runs without error, but it finds no "TRUE" conditions so every value is called "sheet" yet I have validated these values do exist in the data. What am I doing wrong?


data.frame(stringsAsFactors=FALSE,
+    ccmasterid = c("D18385      ", "D18448      ", "D18448      ",
+                   "D18419X     ", "D18385      ", "Z18466      ",
+                   "Z18466      ", "CV2236      ", "CV2236      ", "CV2236      ",
+                   "Z18471      ", "D18376      ", "D18384      ", "Z18451      ",
+                   "D18384      ", "D18214AV    ", "D18214AV    ", "S18275      ",
+                   "D18214AV    ", "D18214AV    "),
+     ccjobpart = c("01   ", "06   ", "05   ", "01   ", "01   ", "02   ",
+                   "01   ", "03   ", "02   ", "01   ", "01   ", "02   ",
+                   "02   ", "01   ", "01   ", "01   ", "02   ", "01   ", "03   ",
+                   "04   "),
+    icmasterid = c("STY040A05101220                                   ",
+                   "KOM003W06001200                                   ",
+                   "KOM003W06001200                                   ",
+                   "SFB0380W125404896                                 ",
+                   "STY040A05101220                                   ",
+                   "STY040AW125405199                                 ",
+                   "INF50BLK18004296                                  ",
+                   "CV3MIJ40C20W5412                                  ", "CV3MIJ40C20W5412                                  ",
+                   "CV3MIJ40C20W5412                                  ",
+                   "SFB050W125406096                                  ",
+                   "SFB12019W1254042100                               ",
+                   "ECB200B28504855                                   ",
+                   "ULB050W06001200                                   ",
+                   "ECB200B28504855                                   ", "SFB12019W1254050100                               ",
+                   "SFB12019W1254050100                               ",
+                   "ULB100BK0048096                                   ",
+                   "ULB019W1254051099                                 ",
+                   "ULB019W1254051099                                 ")
+ )

JobSS$MatType <- ifelse(JobSS$icmasterid %in% c("MTADHCLREMO05412", "OVL004CLEMBOSS05412", "OVL004CLEMBOSS06112", "OVL005POLYPRM05112", "VBN013W2S012612",
              "CV3M40CMW006012", "CV3MIJ40C20W5412", "PAB020SIGNWRIT04812", "PP008TPQ2BO05712", "PSV008RAMW05412", "VBN0131SDULT05412", "VBN0131SDULT06312", "VBN013W2SBO05412", 'VMG020W04000120', "VMR010WFRP06012", "VPS004CLAD05412", "VPS004WBOPM5412",
              "VPS004WBOPM6012", "VPS004WHFG05412", "VPS004WPRM05412", "VPS004WRMV05412", "VPS3MIJ180C5412", "VPS3MIJ180C6012", "VWP008NOLAR05412", "VWP020DRMAT5412", "VWP020DRMAT6012", "VWP020DRSUE5412", "VWP020DSSUE6012"), "roll", "sheet")
#> Error in JobSS$icmasterid %in% c("MTADHCLREMO05412", "OVL004CLEMBOSS05412", : object 'JobSS' not found

Created on 2019-09-06 by the reprex package (v0.3.0)

A post was merged into an existing topic: ifelse using multiple values

Please do not duplicate open topics