title: mutate with ifelse and grepl in R and create new column with matched string
body: <p>I am trying to create new column with grepl(partial match) and ifelse using mutate.
  I have list of drug names with unit and I want to create new column with these units.
  Here is my drug name samples,</p>
  
  <pre><code> Description
      ZOLEDRONIC ACID INF 4MG/5ML (5ML)
      CALCICHEW D3 FORTE CHEWABLE TABS
      DAYCASE DRUGS
      AKYNZEO (NETUPITANT/PALONOSETRON) HARD CAPS 300MG/0.5MG
      CYCLOPHOSPHAMIDE INF 1MG/ML
      EPIRUBICIN INJ 1MG/ML
      DAYCASE DRUGS
      DAYCASE DRUGS
      ALOXI (PALONOSETRON) INJ 250MCG
      PACLITAXEL INF 1MG/ML
      DEXAMETHASONE VIAL 6.6MG/2ML - USE PSD742
      PACLITAXEL INF 1MG/ML
      RAMUCIRUMAB INF 0.1MG - 100MG
  </code></pre>
  
  <p>Here is my tried code,</p>
  
  <pre><code>units &lt;- c("TABS","INF","SYR","CAPS","INJ","VIAL","SOL","POWDER","GEL","CREAM","LOTION","AMP"," SINGLEJECT","PFS")
  
  drug_name &lt;- drug_name %&gt;% mutate(unit =  grepl(paste(units,collapse = "|"),Description))
  </code></pre>
  
  <p>current output is like this,</p>
  
  <pre><code>Description                                 unit
  ZOLEDRONIC ACID INF 4MG/5ML (5ML)           TRUE
      CALCICHEW D3 FORTE CHEWABLE TABS        TRUE
      DAYCASE DRUGS                           FALSE
      AKYNZEO (NETUPITANT/PALONOSETRON) CAPS  TRUE
      CYCLOPHOSPHAMIDE INF 1MG/ML             TRUE
      EPIRUBICIN INJ 1MG/ML                   TRUE
      DAYCASE DRUGS                           FALSE
      DAYCASE DRUGS                           FALSE
  </code></pre>
  
  <p>I dont want unit in TRUE/FALSE, instead it should specify the exact unit, Like this,</p>
  
  <pre><code>        ZOLEDRONIC ACID INF 4MG/5ML (5ML)       INF
          CALCICHEW D3 FORTE CHEWABLE TABS        TABS
  </code></pre>
  
  <p>I am trying to recode this one but dont know how to do this.
  Also, I need to extract metrics in drug name (4MG/5ML) into a separate column. I can do this in another query but need to do it single query with unit. Not all the drugs have this format some of them like this--> 01.MG-100MG, 250MCG.</p>
  
  <pre><code>            ZOLEDRONIC ACID INF 4MG/5ML (5ML)       INF    4MG/5ML
              CALCICHEW D3 FORTE CHEWABLE TABS        TABS   NA
              CYCLOPHOSPHAMIDE INF 1MG/ML             INF    1MG/ML
              ALOXI (PALONOSETRON) INJ 250MCG         INF    250MCG
  </code></pre>
  
  <p>Can anyone help me to solve this?</p>