Remove non-sleep stages events and reorder dataframe rows using the begin
column.
hypnogram(
events,
labels = c("N3", "N2", "N1", "REM", "AWA"),
startTime = 946681200,
epoch_duration = 30,
plot = FALSE
)
Hypnogram dataframe or plot.
Events dataframe. Dataframe must have begin
(POSIXt
), end
(POSIXt
) and event
Sleep stages labels. Defaults to c("N3","N2","N1","REM","AWA")
.
Hypnogram start time. Used when a hypnodensity dataframe is passed as events. Defaults to 946681200.
Epoch duration in seconds. Used when a hypnodensity dataframe is passed as events. Defaults to 30.
Plot the hypnogram or in not using ggplot2
.
tryCatch({
fpath <- paste0(tempdir(),"/15012016HD.csv")
download.file("https://rsleep.org/data/15012016HD.csv",fpath, method="curl")
events <- read_events_noxturnal(fpath)
unlink(fpath)
hypnogram(events)
}, error = function(e) {
print("Error executing this example, check your internet connection.")
})
Run the code above in your browser using DataLab