% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_nt_fitbit.R
\name{create_sleep_indicator}
\alias{create_sleep_indicator}
\title{Create a sleep presence indicator}
\usage{
create_sleep_indicator(df, bin_minutes = NULL)
}
\arguments{
\item{df}{tbl. Sleep data processed for exclusions. Requires columns:
\code{hrate_excluded}, \code{main_slp}, \code{session_id}, \code{participant_id}, and either
\code{sleep_date} or  \code{dtt}.}

\item{bin_minutes}{numeric, positive whole number or NULL. Width of time bins
in minutes. If NULL (default), data is returned at the sleep-date level.
Otherwise, data is aggregated into bins of the specified width (e.g., 60
for hourly, 1440 for calendar day).
bin data. If FALSE, bins will be created based on the \code{dtt} timestamp column.}
}
\value{
tbl with the following columns:
\itemize{
\item \code{participant_id}: Participant identifier.
\item \code{session_id}: Session identifier, coerced to factor.
\item \code{date}: Date of the sleep period.
\item \code{has_sleep_30}: logical
}
}
\description{
Filters out heart-rate-excluded epochs and non-main sleep periods, then
marks each remaining record with a binary sleep presence flag
(\code{has_sleep_30 = TRUE}). The date column used to represent each record
is determined by \code{offset}: either the pre-computed \code{sleep_date} or a floored
time bin derived from \code{dtt}.
}
\note{
Input dataframe should be output if identify_hr_exclusions() or
identify_hr_recovery() functions. If \code{offset} parameter is \code{NULL}, the
\code{sleep_date} column will be used to bin data. Otherwise, bins will be created
based on the \code{dtt} timestamp column, with bin boundaries aligned to the epoch
start (e.g., 00:00, 01:00 for hourly bins).
}
\keyword{internal}
