Hi,

Good question.  How about :

http://stackoverflow.com/questions/17867553/data-table-join-using-two-columns-from-one-table-and-one-column-from-other
http://stackoverflow.com/questions/17597508/merging-endpoints-of-a-range-with-a-sequence
http://stackoverflow.com/questions/16666183/find-values-in-a-given-interval-without-a-vector-scan

The syntax for range queries is a bit tricky and we hope to make it easier in future :

https://r-forge.r-project.org/tracker/index.php?func=detail&aid=203&group_id=240&atid=978

Matthew


On 08/09/13 05:46, guzzom wrote:
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.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help


_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to