title: Re-creating a bar-code/ID variable from a number of columns
body: <p>I have some data on products with a unique code. I am trying to re-create this code from information in other columns.</p>
  
  <p>The data I have looks like the following;</p>
  
  <pre><code>   UPC               SY    GE    VEND  ITEM 
     &lt;chr&gt;             &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt;
   1 00-01-85674-60002 0     1     85674 60002
   2 00-01-85674-60001 0     1     85674 60001
   3 00-01-85674-60004 0     1     85674 60004
   4 27-01-15502-01124 27    1     15502 1124 
   5 00-01-80020-00001 0     1     80020 1    
   6 00-01-80020-24221 0     1     80020 24221
   7 00-01-80020-31799 0     1     80020 31799
   8 00-01-80020-00004 0     1     80020 4    
   9 00-01-80020-35333 0     1     80020 35333
  10 00-01-80020-00002 0     1     80020 2    
  </code></pre>
  
  <p>I am trying to re-create the <code>UPC</code> column from the <code>SY</code>, <code>GE</code>, <code>VEND</code>and <code>ITEM</code> columns.</p>
  
  <p>The first one is somewhat straight forward.</p>
  
  <p>Add a 0 to the beginning of the <code>SY</code> column, another 0 to the <code>GE</code> column and add in <code>VEND</code> and <code>ITEM</code> - then add dashes inbetween each column.</p>
  
  <p>However I am having problems with rows similar to row 4. If I follow the method previously I would obtain.</p>
  
  <p><code>027-001-15502-01124</code> which would not match up to the other products.</p>
  
  <p>Can somebody point me in the right direction as to how I can go about replicating the same structure as the <code>UPC</code> column from the other 4 columns?</p>
  
  <p>Data:</p>
  
  <pre><code>df &lt;- structure(list(UPC = c("00-01-85674-60002", "00-01-85674-60001", 
  "00-01-85674-60004", "27-01-15502-01124", "00-01-80020-00001", 
  "00-01-80020-24221", "00-01-80020-31799", "00-01-80020-00004", 
  "00-01-80020-35333", "00-01-80020-00002", "00-01-80020-24220", 
  "00-01-80020-10001", "27-01-15502-01125", "00-01-80020-00005", 
  "27-02-15504-05184", "00-01-80022-42230", "27-01-15502-01126", 
  "00-01-80020-00003", "00-01-80020-35332", "06-01-07634-00011", 
  "06-01-07634-00021", "27-01-00007-10404", "00-02-40850-00000", 
  "00-01-40850-02001", "00-01-40850-03001", "00-01-40850-06001", 
  "00-01-40850-00005", "00-01-40850-02005", "00-01-40850-00004", 
  "00-01-40850-02004", "00-01-40850-00001", "00-01-40850-02002", 
  "00-01-40850-03002", "00-01-40850-03006", "00-01-40850-02006", 
  "00-01-40850-00006", "00-01-40850-06010", "00-01-40850-07010", 
  "00-02-40850-03010", "00-01-40850-00003", "06-01-03675-10295", 
  "27-01-15503-00343", "27-01-15504-00629", "06-01-03675-10287", 
  "06-01-03675-10286", "27-01-15503-02068", "06-01-03675-10383", 
  "06-01-03675-10595", "06-02-03675-10187", "27-01-15503-00708", 
  "27-01-15504-00630", "06-01-03675-10195", "06-01-03675-10186", 
  "27-01-15503-03729", "07-01-66895-86000", "27-01-15504-02609", 
  "00-02-72783-00059", "27-01-15503-03887", "00-03-72783-00050", 
  "00-02-72783-00009", "00-02-72783-00300", "27-01-15502-01130", 
  "27-01-15503-01162", "27-01-15504-00631", "00-01-72783-00007", 
  "27-01-15503-03666", "00-01-72783-00033", "00-01-72783-00400", 
  "00-01-72783-00004", "00-01-72783-00200", "27-01-15502-01133", 
  "27-01-15503-01161", "27-01-15504-00633", "00-01-72783-00006", 
  "00-01-72783-00022", "00-01-72783-12100", "00-01-72783-01000", 
  "00-01-07278-30010", "00-01-72783-00100", "00-01-72783-00600", 
  "27-01-15503-00046", "27-01-15504-00632", "00-01-72783-00005", 
  "00-01-72783-00011", "00-01-72783-00066", "00-01-09125-00016", 
  "00-01-09125-00005", "27-01-15503-03375", "00-02-09125-00010", 
  "00-01-09125-00040", "00-01-09125-00146", "00-01-09125-00006", 
  "27-01-15503-03376", "00-02-09125-00030", "00-01-09125-00076", 
  "00-01-09125-00070", "00-02-09125-00020", "00-01-09125-00066", 
  "27-01-15503-03738", "00-01-09125-00007"), SY = c("0", "0", "0", 
  "27", "0", "0", "0", "0", "0", "0", "0", "0", "27", "0", "27", 
  "0", "27", "0", "0", "6", "6", "27", "0", "0", "0", "0", "0", 
  "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", 
  "6", "27", "27", "6", "6", "27", "6", "6", "6", "27", "27", "6", 
  "6", "27", "7", "27", "0", "27", "0", "0", "0", "27", "27", "27", 
  "0", "27", "0", "0", "0", "0", "27", "27", "27", "0", "0", "0", 
  "0", "0", "0", "0", "27", "27", "0", "0", "0", "0", "0", "27", 
  "0", "0", "0", "0", "27", "0", "0", "0", "0", "0", "27", "0"), 
      GE = c("1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
      "1", "1", "1", "1", "2", "1", "1", "1", "1", "1", "1", "1", 
      "2", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
      "1", "1", "1", "1", "2", "1", "1", "1", "1", "1", "1", "1", 
      "1", "1", "2", "1", "1", "1", "1", "1", "1", "1", "2", "1", 
      "3", "2", "2", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
      "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", 
      "1", "1", "1", "1", "1", "1", "2", "1", "1", "1", "1", "2", 
      "1", "1", "2", "1", "1", "1"), VEND = c("85674", "85674", 
      "85674", "15502", "80020", "80020", "80020", "80020", "80020", 
      "80020", "80020", "80020", "15502", "80020", "15504", "80022", 
      "15502", "80020", "80020", "7634", "7634", "7", "40850", 
      "40850", "40850", "40850", "40850", "40850", "40850", "40850", 
      "40850", "40850", "40850", "40850", "40850", "40850", "40850", 
      "40850", "40850", "40850", "3675", "15503", "15504", "3675", 
      "3675", "15503", "3675", "3675", "3675", "15503", "15504", 
      "3675", "3675", "15503", "66895", "15504", "72783", "15503", 
      "72783", "72783", "72783", "15502", "15503", "15504", "72783", 
      "15503", "72783", "72783", "72783", "72783", "15502", "15503", 
      "15504", "72783", "72783", "72783", "72783", "7278", "72783", 
      "72783", "15503", "15504", "72783", "72783", "72783", "9125", 
      "9125", "15503", "9125", "9125", "9125", "9125", "15503", 
      "9125", "9125", "9125", "9125", "9125", "15503", "9125"), 
      ITEM = c("60002", "60001", "60004", "1124", "1", "24221", 
      "31799", "4", "35333", "2", "24220", "10001", "1125", "5", 
      "5184", "42230", "1126", "3", "35332", "11", "21", "10404", 
      "0", "2001", "3001", "6001", "5", "2005", "4", "2004", "1", 
      "2002", "3002", "3006", "2006", "6", "6010", "7010", "3010", 
      "3", "10295", "343", "629", "10287", "10286", "2068", "10383", 
      "10595", "10187", "708", "630", "10195", "10186", "3729", 
      "86000", "2609", "59", "3887", "50", "9", "300", "1130", 
      "1162", "631", "7", "3666", "33", "400", "4", "200", "1133", 
      "1161", "633", "6", "22", "12100", "1000", "30010", "100", 
      "600", "46", "632", "5", "11", "66", "16", "5", "3375", "10", 
      "40", "146", "6", "3376", "30", "76", "70", "20", "66", "3738", 
      "7")), row.names = c(NA, -100L), class = c("tbl_df", "tbl", 
  "data.frame"))
  </code></pre>