% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare_ard.R
\name{compare_ard}
\alias{compare_ard}
\alias{is_ard_equal}
\alias{check_ard_equal}
\title{Compare ARDs}
\usage{
compare_ard(
  x,
  y,
  keys = c(all_ard_groups(), all_ard_variables(), any_of(c("variable", "variable_level",
    "stat_name"))),
  columns = any_of(c("stat_label", "stat", "stat_fmt")),
  tolerance = sqrt(.Machine$double.eps),
  check.attributes = TRUE
)

is_ard_equal(x)

check_ard_equal(x)
}
\arguments{
\item{x}{(\code{card})\cr
first ARD to compare.}

\item{y}{(\code{card})\cr
second ARD to compare.}

\item{keys}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr
columns identifying unique records. The intersection of the selected
columns in both ARDs is used. Default is
\code{c(all_ard_groups(), all_ard_variables(), any_of(c("variable", "variable_level", "stat_name")))}.}

\item{columns}{(\code{\link[dplyr:dplyr_tidy_select]{tidy-select}})\cr
columns to compare between the two ARDs. Default is
\code{any_of(c("stat_label", "stat", "stat_fmt"))}.}

\item{tolerance}{(\code{numeric(1)})\cr
numeric tolerance passed to \code{all.equal()} for numeric comparisons.
Default is \code{sqrt(.Machine$double.eps)}.}

\item{check.attributes}{(\code{logical(1)})\cr
logical passed to \code{all.equal()} indicating whether object attributes
(e.g. names) should be compared. Default is \code{TRUE}.}
}
\value{
a named list of class \code{"ard_comparison"} containing:
\itemize{
\item \code{rows_in_x_not_y}: data frame of rows present in \code{x} but not in \code{y}
(based on key columns)
\item \code{rows_in_y_not_x}: data frame of rows present in \code{y} but not in \code{x}
(based on key columns)
\item \code{compare}: a named list where each element is a data frame containing
the key columns, the compared column values from both ARDs, and a
\code{difference} column with the \code{all.equal()} description for rows where
values differ
}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}\cr
\code{compare_ard()} compares columns of two ARDs row-by-row using a shared set
of key columns. Rows where the column values differ are returned.

The \code{is_ard_equal()} function accepts a \code{compare_ard()}
object, and returns \code{TRUE} or \code{FALSE} depending on whether the comparison
reported difference. \code{check_ard_equal()} returns as error if not equal.
}
\examples{
base <- ard_summary(ADSL, by = ARM, variables = AGE)
compare <- ard_summary(dplyr::mutate(ADSL, AGE = AGE + 1),
  by = ARM,
  variables = AGE
)

compare_ard(base, compare)$compare$stat
}
