new_hypnogram() is the low-level constructor for the hypnor_hypnogram
class used throughout hypnoR. It normalises hypnogram-shaped input –
whether a bare tibble (as produced by zeitR::export_hypnogram() or
read_hypnogram()) or a specially classed object (currently:
mrpheus::export_hypnogram()'s mrpheus_hypnogram) – into the single
internal representation that every other hypnoR function expects.
Usage
new_hypnogram(x, ...)
# Default S3 method
new_hypnogram(
x,
epoch_sec = NULL,
resolution = NULL,
subject_id = NULL,
source = NULL,
...
)
# S3 method for class 'mrpheus_hypnogram'
new_hypnogram(
x,
epoch_sec = NULL,
resolution = NULL,
subject_id = NULL,
source = NULL,
...
)Arguments
- x
A data frame with at minimum
epochandstagecolumns, or an object with a dedicatednew_hypnogram()method (currently:mrpheus_hypnogram). Recognised optional columns:time(POSIXct),subject_id,source.- ...
Passed to methods; currently unused.
- epoch_sec
Epoch duration in seconds. When
xcarries its own epoch duration (e.g. anmrpheus_hypnogram'sepoch_sattribute) that value is used unlessepoch_secis explicitly supplied here. Falls back to30Lwhen no value can be determined from either source.- resolution
"aasm","coarse", orNULL(default). WhenNULL, resolution is auto-detected from the stage labels present inx(or, formrpheus_hypnograminput, taken from itsresolutionattribute).- subject_id
Character or
NULL. Overrides any subject/participant identifier carried byx.- source
Character or
NULL. Overrides any source/scorer label carried byx.