% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/impute_missing.R
\name{impute_missing}
\alias{impute_missing}
\title{Impute missing values in a data.frame or tibble (simple, column-wise)}
\usage{
impute_missing(
  data,
  method = c("mean", "median", "zero", "constant"),
  cols = NULL,
  constant = NULL,
  na_warn_prop = 0.2,
  verbose = FALSE
)
}
\arguments{
\item{data}{A data.frame or tibble containing missing values.}

\item{method}{Character; one of c("mean","median","zero","constant").}

\item{cols}{Optional character vector of column names to impute. Defaults to all
numeric columns in \code{data} that contain at least one NA.}

\item{constant}{Numeric; single value to use when \code{method = "constant"}.}

\item{na_warn_prop}{Numeric in \eqn{[0,1]}; threshold for high-missingness warnings per column.
Default 0.2.}

\item{verbose}{Logical; if TRUE, prints progress and a completion summary. Default FALSE.}
}
\value{
A data.frame/tibble of the same dimensions as \code{data}, with the specified
columns' missing values imputed.
}
\description{
Performs deterministic, per-column imputation for numeric variables:
\itemize{
\item "mean": replace NAs with the column mean
\item "median": replace NAs with the column median
\item "zero": replace NAs with 0
\item "constant": replace NAs with the single value given in \code{constant}
}
}
\details{
Non-numeric columns are left untouched. If \code{cols = NULL}, all numeric columns
that have at least one NA are selected automatically. NA positions are the only
values modified; non-NA entries are preserved as-is.

Quality checks:
\itemize{
\item Warns for high-missingness columns (>= \code{na_warn_prop}).
\item Warns and skips imputation when a column has no non-NA values (mean/median undefined).
\item Coerces only numeric columns; non-numerics in \code{cols} are skipped with a warning.
}
}
\examples{
df <- tibble::tibble(a = c(1, NA, 3), b = c(NA, NA, 2), c = letters[1:3])
impute_missing(df, method = "mean")
impute_missing(df, method = "median", verbose = TRUE)
impute_missing(df, method = "constant", constant = -1, cols = "a")
}
