reduce_rows: Reduce a data frame to the rows that reproduce a failure

View source: R/reduce-rows.R

reduce_rowsR Documentation

Reduce a data frame to the rows that reproduce a failure

Description

Often a bug only shows up with a large data frame, even though a handful of rows is enough to trigger it. reduce_rows() applies ddmin() over the rows of data and returns the smallest subset for which predicate still holds, preserving the original row order. The result is typically small enough to paste into a bug report with dput().

Usage

reduce_rows(
  data,
  predicate,
  algorithm = c("cdd", "ddmin"),
  max_oracle_calls = Inf,
  verbose = FALSE
)

Arguments

data

A data frame.

predicate

A function taking a data frame (a subset of data's rows) and returning a single logical: TRUE when the subset still reproduces the failure of interest.

algorithm

Character. The reduction strategy for the first phase, one of "cdd" (default) or "ddmin". Passed through to ddmin().

max_oracle_calls

Numeric. An upper bound on the number of predicate calls. Passed through to ddmin().

verbose

Logical. If TRUE, report progress.

Value

A data frame containing the one-minimal subset of rows.

See Also

ddmin(), minex().

Examples

df <- data.frame(id = 1:6, value = c(3, 8, 999, 2, 5, 7))
# The failure: any value greater than 100.
reduce_rows(df, function(d) any(d$value > 100))

minex documentation built on Aug. 30, 2026, 1:07 a.m.