Dear List, I am having trouble with a tricky merging task. I have one data sheet that has dates (continuous) that radio collared individuals were monitored via telemetry. I have a different sheet containing data from instances where individuals were recaptured and associated body condition data was recorded (sheet 2). I would like to merge the two sheets by individual and date (I can do this with the merge function) but I would also like to copy the body condition data ahead and behind 15 days (or less if the individual was recorded fewer than 15 days in either direction) from the date it was recorded (this is where I'm stuck). Thank you very much! Grant For example sheet 1 would be merged with sheet 2 to give sheet 3: Sheet 1 ind date 1 01/02/87 1 02/02/87 1 03/02/87 1 04/02/87 1 05/02/87 1 06/02/87 1 07/02/87 1 08/02/87 1 09/02/87 1 10/02/87 1 11/02/87 1 12/02/87 1 13/02/87 1 14/02/87 1 15/02/87 1 16/02/87 1 17/02/87 1 18/02/87 1 19/02/87 1 20/02/87 1 21/02/87 1 22/02/87 1 23/02/87 1 24/02/87 1 25/02/87 1 26/02/87 1 27/02/87 1 28/02/87 1 01/03/87 1 02/03/87 1 03/03/87 1 04/03/87 1 05/03/87 1 06/03/87 1 07/03/87 1 08/03/87 1 09/03/87 1 10/03/87 1 11/03/87 1 12/03/87 1 13/03/87 1 14/03/87 1 15/03/87 1 16/03/87 1 17/03/87 1 18/03/87 1 19/03/87 1 20/03/87 1 21/03/87 1 22/03/87 1 23/03/87 1 24/03/87 Sheet 2 ind BC1 BC2 1 01/02/87 33 3 1 03/03/87 44 3 Sheet 3 ind date BC1 BC2 1 01/02/87 33 3 1 02/02/87 33 3 1 03/02/87 33 3 1 04/02/87 33 3 1 05/02/87 33 3 1 06/02/87 33 3 1 07/02/87 33 3 1 08/02/87 33 3 1 09/02/87 33 3 1 10/02/87 33 3 1 11/02/87 33 3 1 12/02/87 33 3 1 13/02/87 33 3 1 14/02/87 33 3 1 15/02/87 33 3 1 16/02/87 NA NA 1 17/02/87 NA NA 1 18/02/87 44 3 1 19/02/87 44 3 1 20/02/87 44 3 1 21/02/87 44 3 1 22/02/87 44 3 1 23/02/87 44 3 1 24/02/87 44 3 1 25/02/87 44 3 1 26/02/87 44 3 1 27/02/87 44 3 1 28/02/87 44 3 1 01/03/87 44 3 1 02/03/87 44 3 1 03/03/87 44 3 1 04/03/87 44 3 1 05/03/87 44 3 1 06/03/87 44 3 1 07/03/87 44 3 1 08/03/87 44 3 1 09/03/87 44 3 1 10/03/87 44 3 1 11/03/87 44 3 1 12/03/87 44 3 1 13/03/87 44 3 1 14/03/87 44 3 1 15/03/87 44 3 1 16/03/87 44 3 1 17/03/87 44 3 1 18/03/87 44 3 1 19/03/87 44 3 1 20/03/87 44 3 1 21/03/87 NA NA 1 22/03/87 NA NA 1 23/03/87 NA NA 1 24/03/87 NA NA [[alternative HTML version deleted]]
Hi Grant, I don't have a solution, but just to be clearer on your situation: One row from sheet 2 looks like this: BC1 BC2 1 01/02/87 33 3 1 03/03/87 44 3 ? Are you using only the first 6 columns for the data to be replicated, and using the other columns as some sort of indicators on when a sequence ends? If so, I would suggest asking the group how you might be able to turn sheet 2 so that it will have as many rows as you needs (which you will then merge with sheet 1). And for clarity sake, consider using ?dput for your objects. Looking at data the way you pasted them (also, without column names) is not very easy for the reader (which might reduce your chances of getting help). Cheers, Tal ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Sun, Feb 27, 2011 at 6:41 PM, Grant Gillis <grant.j.gillis@gmail.com>wrote:> BC1 BC2 1 01/02/87 33 3 1 03/03/87 44 3[[alternative HTML version deleted]]
Reasonably Related Threads
- tricky (for me) merging of data...more clarity
- Wilcoxon test
- How do I retrieve column and row names after comparing two matrices?
- adding copies of rows toa data frame based upon start and end dates
- validate (package Design): error message "subscript out of bounds"