Quickly check for implicit missing Datetime
data. Outputs a message with a
short summary, and can optionally return the gaps as a tibble
. Uses
gap_handler()
internally.
gap_finder(
dataset,
Datetime.colname = Datetime,
epoch = "dominant.epoch",
gap.data = FALSE,
silent = FALSE,
full.days = FALSE
)
Prints message with a short summary of the gaps in the dataset. If
gap.data = TRUE
, returns a tibble
of the gaps in the dataset.
A light logger dataset. Needs to be a dataframe.
The column that contains the datetime. Needs to be a
POSIXct
and part of the dataset.
The epoch to use for the gapless sequence. Can be either a
lubridate::duration()
or a string. If it is a string, it needs to be
either '"dominant.epoch"' (the default) for a guess based on the data or a valid lubridate::duration()
string, e.g., "1 day"
or "10 sec"
.
Logical. If TRUE
, returns a tibble
of the gaps in the
dataset. Default is FALSE
.
Logical. If TRUE
, suppresses the message with the summary of
the gaps in the dataset. Default is FALSE
. Only used for unit tests.
If TRUE
, the gapless sequence will include the whole first and last day where there is data.
The gap_finder()
function is a wrapper around gap_handler()
with the
behavior
argument set to "gaps"
. The main difference is that
gap_finder()
returns a message with a short summary of the gaps in the
dataset, and that the tibble
with the gaps contains a column gap.id
that
indicates the gap number, which is useful to determine, e.g., the consecutive
number of gaps between measurement data.
Other regularize:
dominant_epoch()
,
gap_handler()
,
gapless_Datetimes()
dataset <-
tibble::tibble(Id = c("A", "A", "A", "B", "B", "B"),
Datetime = lubridate::as_datetime(1) +
lubridate::days(c(0:2, 4, 6, 8)) +
lubridate::hours(c(0,12,rep(0,4)))) %>%
dplyr::group_by(Id)
dataset
#look for gaps assuming the epoch is the dominant epoch of each group
gap_finder(dataset)
#return the gaps as a tibble
gap_finder(dataset, gap.data = TRUE)
#assuming the epoch is 1 day, we have different gaps, and the datapoint at noon is now `irregular`
gap_finder(dataset, epoch = "1 day")
Run the code above in your browser using DataLab