I am trying to combine two dataframes where the common denominator is time. However, time records may differ between them. I want to combine the two in time, but with an interval of 30 minutes in the buffer.
dataframes conceptually configured as follows:
Data_cam <- data.frame(Start_haul=c(("31-10-2015 07:13:00"),("31-10-2015 22:40:00"),("01-11-2015 06:48:00"),("01-11-2015 16:13:00")), VesselID=c('XBBX','XBBX','XAAX','XAAX'), Species=("TOR"), Discard=c(0.28,0.96,2.92,0)) Data_sif <- data.frame(Start_haul=c(("31-10-2015 07:05:00"),("31-10-2015 07:05:00"),("31-10-2015 07:05:00"),("31-10-2015 23:05:00"),("31-10-2015 23:05:00"),("01-11-2015 06:28:00"),("01-11-2015 06:28:00"),("01-11-2015 06:28:00"),("01-11-2015 16:11:00")), VesselID=c('XBBX','XBBX','XBBX','XBBX','XBBX','XAAX','XAAX','XAAX','XAAX'),Species=("TOR"), Size_class=c("1","2","3","4","5","1","2","4","5"), Landing_kg=c(10.5,20.5,5.6,400,2,120,250,10.3,2.1))
This means that the first three rows in Data_sif correspond to the first row in Data_cam, and I want to add a βCancelβ column from the first row in Data_cam to the first three rows in Data_sif. Similarly, the 4th and 5th rows in Data_sif correspond to the second row in Data_cam, and I want to add βCancelβ here, etc. For all lines. The value in the Undo column should be repeated for each value displayed in the Class_Size column for a common timestamp.
The desired result will look like this:
Data_combined <- data.frame(Start_haul=c(("31-10-2015 07:05:00"),("31-10-2015 07:05:00"),("31-10-2015 07:05:00"),("31-10-2015 23:05:00"),("31-10-2015 23:05:00"),("01-11-2015 06:28:00"),("01-11-2015 06:28:00"),("01-11-2015 06:28:00"),("01-11-2015 16:11:00")), VesselID=c('XBBX','XBBX','XBBX','XBBX','XBBX','XAAX','XAAX','XAAX','XAAX'),Species=("TOR"), Size_class=c("1","2","3","4","5","1","2","4","5"), Landing_kg=c(10.5,20.5,5.6,400,2,120,250,10.3,2.1), Discard=c(0.28,0.28,0.28,0.96,0.96,2.92,2.92,2.92,0))
I want to add more columns to the final implementation, including positional data, but for simplicity I would like to start by combining the Discard column.
I tried old posts but could not implement it for the data that I have.