% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/m2dt_utils.R
\name{get_analysis_counts}
\alias{get_analysis_counts}
\title{Count the observations available to an analysis}
\usage{
get_analysis_counts(
  data,
  outcome_vars,
  predictor_vars = NULL,
  event_var = NULL
)
}
\arguments{
\item{data}{Data frame or data.table supplied to the analysis.}

\item{outcome_vars}{Character vector of response variable names.}

\item{predictor_vars}{Character vector of predictor variable names, or a list
of such vectors when several models are described.}

\item{event_var}{Character name of the event indicator, or \code{NULL} for
models that carry no event count. Factors are coded as the modeling
functions code them, with any level beyond the first counting as an event.}
}
\value{
Named list with \code{n_supplied}, \code{n_analyzed},
  \code{n_missing_outcome} and \code{n_missing_predictor}, and, where an
  event indicator was supplied, \code{events_supplied} and
  \code{events_analyzed}. \code{NULL} when the counts cannot be determined.
}
\description{
Summarizes how many of the supplied observations could enter a model, and
separates those excluded for a missing response from those excluded for a
missing covariate. The distinction matters: a missing response and a missing
covariate raise different questions about whether a complete-case analysis is
appropriate.
}
\details{
Several models may be described at once by passing a list of predictor sets,
as when a univariable screen fits one model per predictor. The analyzed count
is then returned as one element per set.
}
\keyword{internal}
