sts_combine {MazamaTimeSeries} | R Documentation |
Combine multiple sts time series objects
Description
Create a merged timeseries using of any number of sts objects for a single sensor. If sts objects are non-contiguous, the resulting sts will have gaps.
An error is generated if the incoming sts objects have
non-identical deviceDeploymentIDs
.
Usage
sts_combine(..., replaceMeta = FALSE)
Arguments
... |
Any number of valid SingleTimeSeries sts objects associated
with a single |
replaceMeta |
Logical specifying whether to allow replacement of metadata. |
Value
A SingleTimeSeries sts time series object containing
records from all incoming sts
time series objects.
(A list with meta
and data
dataframes.)
Note
Data are combined with a "later is better" sensibility where any data overlaps exist. To handle this, incoming sts objects are first split into "shared" and "unshared" parts.
Any "shared" parts are ordered based on the
time stamp of their last record. Then dplyr::distinct()
is used to
remove records with duplicate datetime
fields. Any data records found
in "later" sts objects are preferentially retained before the "shared"
data are finally reordered by ascending datetime
.
The final step is combining the "shared" and "unshared" parts.
Examples
library(MazamaTimeSeries)
aug01_08 <-
example_sts %>%
sts_filterDate(20180801, 20180808)
aug15_22 <-
example_sts %>%
sts_filterDate(20180815, 20180822)
aug01_22 <- sts_combine(aug01_08, aug15_22)
plot(aug01_22$data$datetime)