Skip to contents

Assembles a single 24-hour glucose cycle aligned to a sleep-wake episode, spanning sleep onset and the subsequent wake period. This function is intentionally agnostic about the source of the sleep-wake episode: it accepts a plain data frame rather than a package-specific object, so that sugaR does not depend on zeitR, hypnoR, or slumbR prior to their publication on r-universe (per the ecosystem's isolation principle). Callers integrating with those packages are expected to coerce their sleep-episode objects into the expected shape before calling this function.

Usage

build_glucose_cycle(cgm, sleep_episode)

Arguments

cgm

A data frame of CGM data with columns time (POSIXct) and glucose (numeric).

sleep_episode

A data frame or list with elements/columns sleep_onset and wake_offset (both POSIXct scalars), describing a single validated sleep-wake episode.

Value

An object of class sugaR_cycle (see glucose_cycle()).