test_errors: Compare numeric variables in a data frame based on...

View source: R/test_errors.R

test_errorsR Documentation

Compare numeric variables in a data frame based on root-squared differences

Description

Compare numeric variables in a data frame based on root-squared differences

Usage

test_errors(
  reference,
  target,
  vars,
  tolerance = 0.001005,
  return_logical = TRUE
)

Arguments

reference

a data frame giving reference data

target

a data frame giving target data

vars

character vector of variable names to compare in each data frame

tolerance

allowable difference between numeric values

return_logical

logical. Should result be given as a logical vector (indicating TRUE/FALSE equality within tolerance) or a data frame of error summary values?

Value

If return_logical = TRUE, a named logical vector with one element per variable compared, indicating whether the maximum and root-mean-squared differences fall within the tolerance. If return_logical = FALSE, a data frame indicating the variables compared and the maximum and root-mean-squared differences.

Note

It is assumed that reference and target have equal numbers of rows.

Examples

reference <- data.frame(
a = 1:100, b = 75:174
)

target <- data.frame(
  a = 0.001 + (1:100),
  b = 76:175
)

test_errors(reference, target, c("a", "b"))
test_errors(reference, target, c("a", "b"), return_logical = FALSE)

PAutilities documentation built on Aug. 21, 2022, 9:05 a.m.