% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/api-estimation.R
\name{recode_missing_codes}
\alias{recode_missing_codes}
\title{Recode common missing-value sentinels to \code{NA}}
\usage{
recode_missing_codes(
  data,
  columns = NULL,
  codes = c("99", "999", "-1", "N", "NA", "n/a", ".", ""),
  numeric_codes = TRUE,
  verbose = FALSE
)
}
\arguments{
\item{data}{A data frame.}

\item{columns}{Character vector of column names to recode. Defaults
to \code{NULL}, in which case all columns are scanned.}

\item{codes}{Character vector of code values to convert to \code{NA}.
Defaults to the FACETS / SPSS / SAS conventions; override when
your instrument uses different sentinels.}

\item{numeric_codes}{Logical; if \code{TRUE} (default), numeric columns
are also compared against the numeric conversion of \code{codes}.}

\item{verbose}{Logical; if \code{TRUE}, emits a \code{message()} summary of
per-column replacement counts.}
}
\value{
The input \code{data} with the specified missing sentinels
replaced by \code{NA}. A \code{mfrm_missing_recoding} attribute records the
per-column replacement counts for traceability logs.
}
\description{
Convenience helper that replaces the standard non-\code{NA} missing-code
sentinels used in SPSS / SAS / FACETS exports (\code{99}, \code{999}, \code{-1},
\code{"N"}, \code{"NA"}, \code{"n/a"}, \code{"."}, \code{""}) with \code{NA} across the columns
you select. This is the R counterpart of the preprocessing UI in
the companion Streamlit app and is useful before calling
\code{\link[=fit_mfrm]{fit_mfrm()}} on data exported with those conventions.
}
\examples{
dat <- data.frame(
  Person = paste0("P", 1:5),
  Rater = c("R1", "R1", "R2", "R2", "R2"),
  Score = c(1, 99, 2, -1, 3)
)
cleaned <- recode_missing_codes(dat, columns = "Score")
cleaned$Score
attr(cleaned, "mfrm_missing_recoding")
}
\seealso{
\code{\link[=describe_mfrm_data]{describe_mfrm_data()}}, \code{\link[=fit_mfrm]{fit_mfrm()}}.
}
