The mergeData()
is used to combine multiple R6 encapsulations.
The data have to be in HydroImport
or HydroAggs
classes. Depending on the
metadata argument, metadata can be exported with the merged dataset as a
list. The merging process is carried out on looped full joins, this allows
datasets f varying lengths to be collated. Missing information is padded
with NAs.
Arguments
- ...
Datasets downloaded from the EAs API set inside an R6 container
- metadata
Set to FALSE, if TRUE collated metadata are exported with the merged dataset
Examples
a <- loadAPI(ID = 2001,
measure = 'flow',
period = 900,
type = 'instantaneous',
datapoints = 'range',
from = '2023-06-12 09:00',
to = '2023-06-13 09:00')
#> ℹ Compiling parameters for raw download
#> ✔ Compiling parameters for raw download [325ms]
#>
#> ℹ Downloading raw data
#> ✔ Downloading raw data [186ms]
#>
#> ℹ Collating metadata
#> ✔ Collating metadata [244ms]
#>
#> ℹ Exporting data to HydroImport container
#> ✔ Exporting data to HydroImport container [46ms]
#>
b <- loadAPI(ID = 2002,
measure = 'flow',
period = 900,
type = 'instantaneous',
datapoints = 'range',
from = '2023-06-12 09:00',
to = '2023-07-12 09:00')
#> ℹ Compiling parameters for raw download
#> ✔ Compiling parameters for raw download [343ms]
#>
#> ℹ Downloading raw data
#> ✔ Downloading raw data [358ms]
#>
#> ℹ Collating metadata
#> ✔ Collating metadata [235ms]
#>
#> ℹ Exporting data to HydroImport container
#> ✔ Exporting data to HydroImport container [42ms]
#>
c <- loadAPI(ID = 2004,
measure = 'flow',
period = 900,
type = 'instantaneous',
datapoints = 'range',
from = '2023-06-13 09:00',
to = '2023-07-12 09:00')
#> ℹ Compiling parameters for raw download
#> ✔ Compiling parameters for raw download [169ms]
#>
#> ℹ Downloading raw data
#> ✔ Downloading raw data [343ms]
#>
#> ℹ Collating metadata
#> ✔ Collating metadata [238ms]
#>
#> ℹ Exporting data to HydroImport container
#> ✔ Exporting data to HydroImport container [56ms]
#>
d <- loadAPI(ID = 2001,
measure = 'level',
period = 900,
type = 'instantaneous',
datapoints = 'range',
from = '2023-06-12 09:00',
to = '2023-07-12 09:00')
#> ℹ Compiling parameters for raw download
#> ✔ Compiling parameters for raw download [174ms]
#>
#> ℹ Downloading raw data
#> ✔ Downloading raw data [325ms]
#>
#> ℹ Collating metadata
#> ✔ Collating metadata [359ms]
#>
#> ℹ Exporting data to HydroImport container
#> ✔ Exporting data to HydroImport container [58ms]
#>
z <- mergeData(a, b, c, d, metadata = FALSE)
#> Warning: Different parametrs will be collated, this could lead to problems in other analyses
z
#> Key: <dateTime>
#> dateTime a_value b_value c_value d_value
#> <POSc> <num> <num> <num> <num>
#> 1: 2023-06-12 09:00:00 15.4 12.3 NA 0.341
#> 2: 2023-06-12 09:15:00 15.1 12.6 NA 0.338
#> 3: 2023-06-12 09:30:00 15.2 12.4 NA 0.336
#> 4: 2023-06-12 09:45:00 15.1 12.5 NA 0.334
#> 5: 2023-06-12 10:00:00 14.8 12.5 NA 0.334
#> ---
#> 2877: 2023-07-12 08:00:00 NA 11.4 3.70 0.306
#> 2878: 2023-07-12 08:15:00 NA 11.6 3.76 0.308
#> 2879: 2023-07-12 08:30:00 NA 11.7 3.87 0.307
#> 2880: 2023-07-12 08:45:00 NA 11.5 3.95 0.310
#> 2881: 2023-07-12 09:00:00 NA 11.6 4.03 0.308