jeudi 30 novembre 2017

Select dates only within a range of dates in another sheet by animal ID

I have two data sheets, one containing bird movement data at 30 minute intervals and another containing date ranges within which the birds were nesting. I am only interested in looking at the movement data within the nesting ranges (using short dates only). Here's a simplified example of the data (I have thousands of rows IRL):

Data frame 1:
Bird_ID     Date        
A           4/5/2015 
A           4/20/2015
A           4/28/2015
B           5/6/2016
B           5/30/2016
C           3/4/2014
C           3/9/2014

Data frame 2:
Bird_ID     Nest_start     Nest_end
A           4/2/2015       4/15/2015
B           5/21/2016      6/3/2016
C           4/1/2014       4/15/2014

I am looking for output like this:

Data frame 1.1:
Bird_ID     Date        Keep (0=no, 1=yes)?  
A           4/5/2015    1
A           4/20/2015   0
A           4/28/2015   0
B           5/6/2016    0
B           5/30/2016   1
C           3/4/2014    0
C           3/9/2014    0

Columns are of different lengths. I have encountered errors following the methods from other posts (but sorry if this is a repeat anyway!). Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire