title: I want to join two data frames one with a year range and the other with a year
body: <p>I have two data frames that look like this</p>
  <pre><code>data1&lt;-data.frame(name=c(&quot;Jessica_Smith&quot;,&quot;John_Smith&quot;,&quot;John_Smith&quot;) ,
  max_year=c(2000,1989,2005), 
  min_year=c(1990,1989,2001))
  
  data2&lt;-data.frame(name=c(&quot;Jessica_Smith&quot;,&quot;John_Smith&quot;,&quot;John_Smith&quot;) ,
  year_of_birth=c(1995,1989,2002),unique_id=c(&quot;aby37&quot;,&quot;nf93&quot;,&quot;fnd34&quot;))
  
  </code></pre>
  <p>I would like to merge the data frames such that for each person in data1 I have a unique_id. If possible I would also like to get the nearest integer match for those for whom there is no overlap. To clarify I can't just left_join on name because some entries have the same name but different dates of birth.</p>
  <p>I'm relatively new to R so I don't even really know where to begin.</p>
  <p>Much appreciated!</p>