% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_nt_fitbit.R
\name{compute_sleep_stage_min}
\alias{compute_sleep_stage_min}
\title{Compute total minutes by sleep stage}
\usage{
compute_sleep_stage_min(data, bin_minutes = NULL)
}
\arguments{
\item{data}{tbl. Dataframe for sleep data processed for exclusions, requires
columns \code{is_slp}, \code{session_id}, \code{sleep_date} or \code{dtt}, \code{hrate_excluded}, and
\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{min_total_slp}: Total number of main sleep minutes
\item \code{min_asleep_slp}: Total number of main sleep minutes in asleep stage.
\item \code{min_restless_slp}: Total number of main sleep minutes in restless stage.
\item \code{min_light_slp}: Total number of main sleep minutes in light stage.
\item \code{min_deep_slp}: Total number of main sleep minutes in deep stage.
\item \code{min_rem_slp}: Total number of main sleep minutes in REM stage.
\item \code{min_nap_slp}: Total number of non-main sleep minutes.
\item \code{min_wake}: Total number of main sleep minutes spent in wake 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{
Computes valid minutes spent in each sleep stage by offset date or by
specified time bins (e.g., 15-min, 30-min), not excluded by heart rate
criteria.
}
\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).
}
\keyword{internal}
