Preview data-selection filtering

Description

Applies IGNORE/ACCEPT record-level filters to a NONMEM dataset in pure R, approximating the semantics of the [data_selection] model block. This is a preview function: the canonical, engine-validated filtering happens in Rust at fit time. The R-side implementation is intentionally lenient: unparseable expressions and unknown column names are silently treated as non-matching (no exclusion), whereas Rust will error on invalid filters. Use ferx_selection() to inspect which records will be excluded before committing to a fit, or to pass pre-built conditions directly to [ferx_fit](ferx_fit.qmd).

Usage

ferx_selection(data, ignore = NULL, accept = NULL, ignore_ids = NULL)

Arguments

  • data: Character path to a NONMEM CSV file, or a data.frame already read into memory. When a path is supplied it is recorded on the returned object so [ferx_fit](ferx_fit.qmd)(data = <result>) can pass it through to Rust without writing a temporary file.
  • ignore: Character vector of filter expressions. A record is excluded when any expression evaluates to TRUE. Expressions use column names with standard comparison operators (==, !=, <, <=, >, >=); use && for AND within one expression. Example: c("DV < 0.001", "EVID != 0").
  • accept: Character vector of filter expressions. A record is kept only when all conditions pass; excluded if any fail.
  • ignore_ids: Numeric or character vector of subject IDs to exclude entirely.

Seealso

[ferx_selection_excluded](ferx_selection_excluded.qmd) to retrieve excluded rows; [ferx_fit](ferx_fit.qmd) which accepts a ferx_data object as data. Other data selection: [ferx_selection_excluded](ferx_selection_excluded.qmd)()

Concept

data selection

Value

An object of class "ferx_data" (also a data.frame) containing the retained records. The following attributes carry metadata:

  • source_path: Character path supplied as data, or NULL when data was a data.frame.
  • ignore, accept, ignore_ids: The filter conditions used (character / character / character vectors).
  • excluded_rows: A data.frame of the excluded records with an extra column .exclude_reason (first matching rule string).
  • exclusions: A named list mirroring fit$exclusions: n_records_total, n_obs_excluded, n_dose_excluded, n_other_excluded, excluded_subject_ids, fired_ignore, fired_accept.