How to matching water level data into flux with different timeseries

Note that, waterhead data (Set A) was 30minutes interval. While flux data (Set B) was 3-4 seconds interval. So, I think I would like to average the flux data, but match them with the same month reading with water table.

Dataset A

datetime waterhead
01/02/2016 00:00 118.575
01/02/2016 00:30 118.392
01/02/2016 01:00 118.717
01/02/2016 01:30 118.45
01/02/2016 02:00 118.508
01/02/2016 02:30 118.45
01/02/2016 03:00 118.742
01/02/2016 03:30 118.45
01/02/2016 04:00 118.6

Dataset B

datetime CO2.flux_qc
15/08/2016 08:26 1.4102
15/08/2016 08:31 1.209
15/08/2016 08:34 1.79795
15/08/2016 08:38 0.9397
15/08/2016 08:41 1.0944
15/08/2016 08:44 0.9629
15/08/2016 08:48 0.9104

Cheers,
Mha

You can make a new rounded date column in the second data set, rounding each datetime to the nearest 30 minutes, and then use that column when joining the data to the first data set.

library(lubridate)
DF <- data.frame(Datetime = c("15/08/2016 08:31", "15/08/2016 08:34",
                 "15/08/2016 08:38", "15/08/2016 08:41", "15/08/2016 08:44",
                 "15/08/2016 08:48"))
DF$Datetime <- dmy_hm(DF$Datetime) #convert to numeric time
DF$RndDate <- round_date(DF$Datetime, unit = "30 minutes")

DF
#>              Datetime             RndDate
#> 1 2016-08-15 08:31:00 2016-08-15 08:30:00
#> 2 2016-08-15 08:34:00 2016-08-15 08:30:00
#> 3 2016-08-15 08:38:00 2016-08-15 08:30:00
#> 4 2016-08-15 08:41:00 2016-08-15 08:30:00
#> 5 2016-08-15 08:44:00 2016-08-15 08:30:00
#> 6 2016-08-15 08:48:00 2016-08-15 09:00:00

Created on 2020-11-10 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Hi,

Thank you very much.

It is working.

Cheers,
MHA