Skip to contents

Returns TRUE if there are irregular data in the dataset and FALSE if not. Irregular data can make sense if two datasets within a single group are shifted to one another, e.g., if it contains data from two separate recording sessions. The second session will be unlikely to have started at the exact interval timing of the first session. While this is not problematic in itself, it is still recommended to rectify the Datetimes to a common timestamp if time precision permits it, e.g., through aggregate_Datetime() or cut_Datetime().

Usage

has_irregulars(dataset, Datetime.colname = Datetime, epoch = "dominant.epoch")

Arguments

dataset

A light logger dataset. Needs to be a dataframe.

Datetime.colname

The column that contains the datetime. Needs to be a POSIXct and part of the dataset.

epoch

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".

Value

logical

See also

Examples

#the sample dataset does not have any irregular data
sample.data.environment |> has_irregulars()
#> [1] FALSE

#even removing some data does not make it irregular, as all the Datetimes
#still fall in the regular interval
sample.data.environment |> dplyr::filter(MEDI <= 50000) |> has_irregulars()
#> [1] FALSE

#shifting some of the data will create irregular data
sample.data.environment |> 
  dplyr::mutate(
   Datetime = dplyr::if_else(
     sample(c(TRUE, FALSE), dplyr::n(), replace = TRUE), Datetime, Datetime + 1
     )
   ) |> 
   has_irregulars()
#> [1] TRUE