% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/audit-transform.R
\name{audit_transform}
\alias{audit_transform}
\alias{print.audit_transform}
\title{Audit a Vector Transformation}
\usage{
audit_transform(
  x,
  clean_fn,
  name = NULL,
  .tolerance = sqrt(.Machine$double.eps)
)

\method{print}{audit_transform}(x, ...)
}
\arguments{
\item{x}{Vector to transform. Accepted types: character, numeric,
Date, POSIXct, factor, or logical.}

\item{clean_fn}{A function applied to \code{x} that returns a vector of the
same length, \strong{or} a pre-computed vector of the same length (used
directly as the transformation result).}

\item{name}{Optional name for the variable (used in output). If \code{NULL},
captures the variable name from the call.}

\item{.tolerance}{Numeric tolerance used for the "changed beyond tolerance"
diagnostic (numeric type only). Defaults to \code{sqrt(.Machine$double.eps)}.}

\item{...}{Additional arguments (currently unused).}
}
\value{
An S3 object of class \code{audit_transform} containing:
\describe{
\item{name}{Name of the variable}
\item{clean_fn_name}{Name of the transformation function, or
\code{"<pre-computed>"} when a vector was supplied directly}
\item{type_class}{Detected type: \code{"character"}, \code{"numeric"},
\code{"Date"}, \code{"POSIXct"}, \code{"factor"}, or \code{"logical"}}
\item{n_total}{Total number of elements}
\item{n_changed}{Count of values that changed (including NA status changes)}
\item{n_unchanged}{Count of values that stayed the same}
\item{n_na_before}{Count of NA values before transformation}
\item{n_na_after}{Count of NA values after transformation}
\item{pct_changed}{Percentage of total elements that changed}
\item{change_examples}{Data frame with before/after pairs (up to 10)}
\item{diagnostics}{Type-specific diagnostic list, or \code{NULL} for character}
\item{cleaned}{The transformed vector, retaining its type}
}
}
\description{
Applies a transformation function to a vector and reports what changed.
Works with any vector type: character, numeric, Date/POSIXct, factor, or
logical. Diagnostics are adapted to the detected input type.
}
\examples{
# Character
x <- c("  hello ", "WORLD", "  foo  ", NA)
result <- audit_transform(x, trimws)
result$cleaned

# Numeric
prices <- c(10.5, 20.0, NA, 30.0)
audit_transform(prices, function(v) round(v))

# Pre-computed result
audit_transform(prices, round(prices))

}
\seealso{
\code{\link[=diagnose_strings]{diagnose_strings()}}

Other data quality:
\code{\link[=diagnose_nas]{diagnose_nas()}},
\code{\link[=diagnose_strings]{diagnose_strings()}},
\code{\link[=get_summary_table]{get_summary_table()}},
\code{\link[=summarize_column]{summarize_column()}},
\code{\link[=tab]{tab()}}
}
\concept{data quality}
