title: R: Find matching string then copying row
body: <p>I have a multi-step problem. First step: match text in one string (df1) from one column to another range of columns (df2). There is no order of which columns match and the match could occur anywhere within the range. Once the match is found, copy the df2 row match into df1. Finally, repeat for the entire column.</p>
  
  <pre><code>df1= structure(list(Assay = c("ATG_AR_trans_up","NVS_PXR_cis","BSK_VCAM1_up"), p.value = c(0.01,0.05,0.0001)), .Names = c("Assay", "p.value"),row.names = c(NA, 3L), class = "data.frame") 
  
  df1
  Assay               p.value
  ATG_AR_trans_up       0.01
  NVS_hPXR              0.065
  BSK_VCAM1_up          0.001
  
  df2=structure(list(GeneID = c("AR", "VACM1", "TR", "ER", "PXR"), Assay1= c("ATG_ARE_cis", "BSK_hEDG_VCAM1", "NVS_TR_tran", "ATG_ER_UP", "NVS_PXRE_UP"), Assay2= c("ATG_AR_trans_up", "BSK_BE3K_VCAM1", "NA", "ATG_ERE_cis", "ATG_PXRE_cis"), Assay3= c("NVS_AR_trans", "BSK_VCAM1_UP", "NA", "NVS_ERa_CIS", "NVS_PXR_cis"), Assay4= c("Tox21_AR_ARE","NA", "NA", "Tox21_ERaERb_lig", "NA")),  .Names = c("GeneID", "Assay1", "Assay2", "Assay3", "Assay4"),row.names = c(NA, 5L), class = "data.frame")
  
  df2  
      GeneID             Assay1            Assay 2           Assay3
      AR                 ATG_ARE_cis       NVS_hAR          ATG_AR_trans_up
      VACM1              BSK_hEGF_CAM1     BSK_VCAM1_up      BSK_VCAM1_down
      TR                 NVS_TR_tran       NA                  NA
      ER                 ATG_ER_UP         ATG_ERE_cis     NVS_ERa_CIS     
      PXR                ATG_PXR_down      ATG_PXRE_cis      NVS_hPXR
  </code></pre>
  
  <p>Essentially becomes</p>
  
  <pre><code>df
  Assay           p.value   GeneID    Assay1       Assay2      Assay3
  ATG_AR_trans_up  0.01      AR      ATG_ARE_cis  NVS_hAR      ATG_AR_trans_up
  NVS_hPXR         0.065    PXR    ATG_PXR_down   ATG_PXRE_cis NVS_hPXR
  BSK_VCAM1_up     0.001    VCAM1  BSK_hEGF_CAM1  BSK_VCAM1_up BSK_VCAM1_down
  </code></pre>
  
  <p>For brevity I shortened the df substantially, but it is around 88 Assays and 4,000 some rows to go through for just one match (there are about 30). So a my initial instinct is to loop, but I was told <code>grep</code> might be a helpful package (even though it is not for R 3.2.2). Any help would be appreciated though.</p>