% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/validate_inputs_before_perturbation.R
\name{validate_inputs}
\alias{validate_inputs}
\title{Validate Inputs Before Perturbation}
\usage{
validate_inputs(data, ptable, geog, tab_vars, record_key, threshold)
}
\arguments{
\item{data}{A \code{data.table} containing the data to be tabulated and perturbed

The data should contain one row per statistical unit (person, household,
business or other) and one column per variable (age, sex, health status)}

\item{ptable}{A \code{data.table} containing the \code{ptable} file which determines
when perturbation is applied.}

\item{geog}{A \verb{character vector} giving the column name in \code{data} that
contains the desired geography level for the frequency table. This can be an
empty vector, \code{c()}, if no geography level is required.}

\item{tab_vars}{A \verb{character vector} giving the column names in \code{data} of the
variables to be tabulated.
This can be an empty vector, \code{c()}, provided a geography level is supplied.}

\item{record_key}{A \code{character} containing the column name in \code{data} giving
the record keys required for perturbation.
If data contains "ons_id" and use_existing_ons_id = TRUE,
set (record_key = NULL), as record key will be generated from "ons_id".}

\item{threshold}{An \code{integer} specifying the value below which counts are
suppressed, with a default value of 10.}
}
\value{
Invisibly returns TRUE on success. Throws stop or Warning messages
if any validation fails.
}
\description{
Validates inputs for a perturbation process.
\itemize{
\item Validate type of input data & ptable
\item Validate other input arguments
\itemize{
\item Check that at least one variable specified for geog or tab_vars
\item Check geog and tab_vars are either character vectors or NULL
\item Check specified record_key is character vector or NULL
\item Check threshold is an integer and non-negative
}
\item Validate microdata and ptable contain required columns
\itemize{
\item Check data contain the specified geog, tab_vars & record_key
\item Check ptable contains required columns
}
\item Validate the range of record keys and cell keys
\item Validate data has sufficient records with record keys to apply perturbation
}
}
\examples{
if (requireNamespace("data.table", quietly = TRUE)) {
  data.table::setDTthreads(1)
}
validate_inputs(data = micro,
                ptable = ptable_10_5,
                record_key = "record_key",
                geog = c("var1"),
                tab_vars = c("var5","var8"),
                threshold = 10)
}
\keyword{internal}
