[datatable-help] Sub setting multiple ids based on a 2nd data frame

guzzom mattguzzo12 at gmail.com
Sun Sep 8 06:46:14 CEST 2013


Hi All,

I have some telemetry data that spans multiple years (2002 - 2013) with
multiple individuals per year. I want to subset the telemetry data to
include only those data points that fall between specific dates which are
provided in a 2nd data frame. The telemetry df is in the form of:

DF "A"

ID	Date	         Depth	Temp
1	2012-05-12	     10	12
1	2012-05-13	     10	12
1	2012-05-14	     10	12
1	2012-05-15	     10	12
2	2012-05-16	     10	12
2	2012-05-17	     10	12
2	2012-05-18	     10	12
2	2012-05-19	     10	12
3	2012-05-20	     10	12
3	2012-05-21	     10	12
3	2012-05-22	     10	12
3	2012-05-23	     10	12
3	2012-05-24	     10	12

And the df with the dates I want to use to subset is formatted as follows:

 DF "B"

Year	   Start	    End
2002	2002-05-10	2002-11-01
2003	2003-05-11	2003-11-02
2004	2004-05-12	2004-11-03
2005	2005-05-13	2005-11-04
2006	2006-05-14	2006-11-05

So, I want to say, for each ID in DF A, subset and keep only those data
points collected on a date that fall between the start and end date for the
corresponding year from DF B.

I am unsure if a loop is my best bet, or using plyr (which I am unfamiliar
with). I am relatively new to R, so this seems a bit above my head. Any help
is much appreciated.

Thanks in advance!



--
View this message in context: http://r.789695.n4.nabble.com/Sub-setting-multiple-ids-based-on-a-2nd-data-frame-tp4675620.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list