title: R: match row-wise from lookup and output result as 1/0
body: <pre><code>set.seed(999)
  lookup &lt;- mtcars[1:6,1:2]       #lookup table
  data &lt;- mtcars[4:7, 1:2]        #my actual data
  data &lt;- data[sample(nrow(data)),]   #shuffle row-wise
  
  data
  lookup &lt;- tibble::rownames_to_column(lookup, "id") 
  data &lt;- tibble::rownames_to_column(data, "id")
  
  data$matchornot &lt;- match(data.frame(t(data)), data.frame(t(lookup)))
  #Code ends
  
  lookup
                   id  mpg cyl
  1         Mazda RX4 21.0   6
  2     Mazda RX4 Wag 21.0   6
  3        Datsun 710 22.8   4
  4    Hornet 4 Drive 21.4   6
  5 Hornet Sportabout 18.7   8
  6           Valiant 18.1   6
  
  
  data
                       mpg cyl
  1 Hornet Sportabout 18.7   8
  2        Duster 360 14.3   8
  3    Hornet 4 Drive 21.4   6
  4           Valiant 18.1   6
  
  
  My output:
                   id  mpg cyl matchornot
  1 Hornet Sportabout 18.7   8          1
  2        Duster 360 14.3   8          1 #&lt;--There's no Duster model in lookup, suppose to be 0
  3    Hornet 4 Drive 21.4   6          1
  4           Valiant 18.1   6          1
  </code></pre>
  
  <p>Hi, would like to find row-wise intersection of a data frame via referring to a lookup table, if there's exact match (row-wise), 1/0 is applied</p>
  
  <p>thanks</p>
  
  <p>*updated v1:
  Apologies for not being concise enough..</p>
  
  <p>The entire row have to be matched 100%. For example, if Valiant model is 99.0 mpg, your output data$matchornot for that model is "0"</p>