seamless: is_seamless, seamless

View source: R/seamless.R

seamlessR Documentation

is_seamless, seamless

Description

is_seamless checks if a given history (i.e. a succession of intervals) is seamless, i.e. stop timepoints of preceding coincide with start timepoints of succeeding intervals. Conversion of a not seamless into a seamless history can be attempted with seamless.

Usage

is_seamless(d, begin = begin, end = end)

seamless(d, begin = begin, end = end)

Arguments

d

table

begin

tidyr selector specifying column containing begin timepoints

end

tidyr selector specifying column containing end timeponts

Value

is_seamless returns a logical stating whether history is seamless or not

seamless returns a tibble that is seamless, i.e. satisfies is_seamless

Examples

# set seed to make it reproducible
set.seed(3)
# generate random numbers between 0 and 1e6
rn <- runif(5, 0, 1e6)
# generate intervals in seconds
ir <- rn + runif(5, 0, 1e6)
# generate random history `hx` (table)
hx <- data.frame(unit = sample(letters[1:3], 5, TRUE),
begin = as.POSIXlt(rn, origin = "2021-01-01 00:00:00"),
end = as.POSIXlt(ir, origin = "2021-01-01 00:00:00"))
# hx is expected to not be seamless
is_seamless(hx) # returns FALSE

# hx can, however, be converted
## Not run: 
sl_hx <- seamless(hx)
is_seamless(sl_hx) # returns TRUE

## End(Not run)

joheli/kungfu documentation built on March 25, 2024, 10:10 a.m.