% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_nt_fitbit.R
\name{compute_sleep_stage_hr}
\alias{compute_sleep_stage_hr}
\title{Compute daily average heart rate}
\usage{
compute_sleep_stage_hr(data, bin_minutes = NULL)
}
\arguments{
\item{data}{tbl. Data frame heart rate columns \code{is_slp}, \code{session_id},
\code{sleep_date} or \code{dtt}, \code{hrate}, \code{hrate_excluded}, \code{stage}.}

\item{bin_minutes}{numeric, positive whole number. Optional number of minutes
to bin data by. If NULL, defaults to sleep_date column created from
\code{make_offset} function.}
}
\value{
tbl. The input data frame with the following additional columns:
\itemize{
\item \code{hrate_awake_slp}: Mean heart rate during wake stage, includes awake and
NULL stage minutes from extended framework.
\item \code{hrate_restless_slp}: Mean heart rate during 'restless' stage
\item \code{hrate_asleep_slp}: Mean heart rate during 'asleep' stage
\item \code{hrate_light_slp}: Mean heart rate during 'light' stage
\item \code{hrate_deep_slp}: Mean heart rate during 'deep' stage.
\item \code{hrate_rem_slp}: Mean heart rate during 'rem' stage.
\item \code{start}: Start timestamp of the bin.
\item \code{end}: End timestamp of the bin.
}

\code{start} and \code{end} are only present when \code{bin_minutes} is non-\code{NULL} and
not equal to \code{1440}.
}
\description{
Calculates mean heart rate within each sleep stage, either by sleep date or
aggregated into fixed-width time bins (e.g., 15, 30, or 60 minutes). Epochs
flagged by heart rate criteria are included.
}
\note{
input data should be output of \code{join_sleep30_and_exclusion()}. Input
data must be in 30-second epochs. \code{min_wake} includes minutes with stage of
"wake", "awake", "unknown", or NA  (for activity minutes that become sleep
under extended framework). All \code{hrate_} columns are rounded to one decimal
place.
}
\keyword{internal}
