Learn R Programming

rsleep (version 1.0.4)

hypnogram: Filter and reorder an events dataframe to keep only sleep stages related-events.

Description

Remove non-sleep stages events and reorder dataframe rows using the begin column.

Usage

hypnogram(events, labels = c("N3", "N2", "N1", "REM", "AWA"))

Value

hypnogram dataframe.

Arguments

events

Events dataframe. Dataframe must have begin (POSIXt), end (POSIXt) and event

labels

Sleep stages labels. Defaults to c("N3","N2","N1","REM","AWA").

Examples

Run this code
e <- data.frame(begin = as.POSIXlt(c(1536967800,1536967860,1536967830),origin = "1970-01-01"))
e$end <- as.POSIXlt(c(1536967830,1536967890,1536967860), origin = "1970-01-01")
e$event = c("back-position","N3","REM")
hypnogram(e)

Run the code above in your browser using DataLab