Learn R Programming

rsleep (version 1.0.12)

plot_hypnodensity: Plot a hypnodensity graph.

Description

Plot a hypnodensity graph using `ggplot2`. Hypnodensity can be read from file or returned by the `score_stages_edf` function.

Usage

plot_hypnodensity(
  hypnodensity,
  stages = c("AWA", "REM", "N1", "N2", "N3"),
  colors = c("#5BBCD6", "#FF0000", "#00A08A", "#F2AD00", "#F98400")
)

Value

A `ggplot2` hypnodensity graph.

Arguments

hypnodensity

A hypnodensity dataframe as returned by the `score_stages_edf` function.

stages

Vector of stages labels to plot.

colors

Vector of colors to use.

References

Stephansen, J.B., Olesen, A.N., Olsen, M., Ambati, A., Leary, E.B., Moore, H.E., Carrillo, O., Lin, L., Han, F., Yan, H. and Sun, Y.L., 2018. Neural network analysis of sleep stages enables efficient diagnosis of narcolepsy. Nature communications, 9(1), p.5229.

Examples

Run this code
tryCatch({
download.file("https://rsleep.org/data/hypnodensity.csv", "hypnodensity.csv")

hypnodensity <- read.csv2("hypnodensity.csv")

unlink("hypnodensity.csv")

plot_hypnodensity(hypnodensity)
}, error = function(e) {
  print("Error executing this example, check your internet connection.")
  })

Run the code above in your browser using DataLab