<div dir="ltr">I'm trying to figure out how to merge two data tables using the dates in both. Â One table a set of people, which has the to and from dates and their address at each place they've lived. Â The other has their work history, also with to and from dates. Â Obviously, there isn't a one-to-one relationship; individuals may have several jobs while staying in the same place, several homes over the course of a job, and any sort of overlapping you can imagine. Â Both tables are reasonably large; the residences has about 950k rows, and the employment has about 1.2M rows.<div>
<br></div><div>To give you a bit of flavor, the first ten rows of each:</div><div><div>> work.history[1:10, list(icrdn, fromdate, todate, state, postalcode)]</div><div>  Â  icrdn fromdate Â  todate state postalcode</div>
<div> 1: Â  145 Apr 1988 Jan 1990 Â  Â FL Â  Â  Â 33432</div><div> 2: Â  145 Jan 1990 Jan 1997 Â  Â FL Â  Â  Â 33432</div><div> 3: Â  145 Jan 1997 Dec 2011 Â  Â FL Â  Â  Â 33444</div><div> 4: Â  145 Jan 1997 Dec 2011 Â  Â FL Â  Â  Â 33444</div><div>
 5: Â  145 Jan 1997 Dec 2011 Â  Â FL Â  Â  Â 33444</div><div> 6: Â  170 Oct 1983 Apr 2002 Â  Â NE Â  Â  Â 68114</div><div> 7: Â  170 Sep 1972 Dec 2011 Â  Â IL Â  Â  Â 60443</div><div> 8: Â  170 Sep 1972 Dec 2011 Â  Â IL 61821-3066</div><div> 9: Â  183 Aug 2000 Dec 2011 Â  Â GA Â  Â  Â 30305</div>
<div>10: Â  183 Aug 2000 Dec 2011 Â  Â GA Â  Â  Â 30305</div><div>> residences[1:10]</div><div>  Â  icrdn fromdate Â todate state postalcode</div><div> 1: Â  145 Â 10/1992 03/2004 Â  Â FL Â  Â  Â 33432</div><div> 2: Â  145 Â 03/2004 Â  Â  Â  Â  Â  Â FL Â  Â  Â 33487</div>
<div> 3: Â  170 Â 09/1995 Â  Â  Â  Â  Â  Â IL Â  Â  Â 61821</div><div> 4: Â  183 Â 05/1993 08/2000 Â  Â GA Â  Â  Â 30342</div><div> 5: Â  183 Â 08/2000 09/2001 Â  Â GA Â  Â  Â 30342</div><div> 6: Â  183 Â 09/2001 08/2004 Â  Â GA Â  Â  Â 30305</div><div>
 7: Â  183 Â 08/2004 Â  Â  Â  Â  Â  Â GA Â  Â  Â 30073</div><div> 8: Â  183 Â 02/2005 Â  Â  Â  Â  Â  Â GA Â  Â  Â 30342</div><div> 9: Â  183 Â 06/2006 Â  Â  Â  Â  Â  Â GA Â  Â  Â 30075</div><div>10: Â  183 Â 07/1974 05/1993 Â  Â GA Â  Â  Â 30338</div></div><div>
<br></div><div>The 'icrdn' column is an identifier unique to each person.</div><div><br></div><div>What I'm looking for is a data table with a row for each residence-job pair. Â Any residence that doesn't have a job in the sample can be safely dropped, and vice-versa.</div>
<div><br></div><div>Thanks in advance for any help anyone can offer.<br clear="all"><div>-------<br>Nathaniel Graham<br><a href="mailto:npgraham1@gmail.com" target="_blank">npgraham1@gmail.com</a><br><a href="mailto:npgraham1@uky.edu" target="_blank">npgraham1@uky.edu</a></div>

</div></div>