fetch.TrialComparison: Fetch Objects from a Trial Comparison

View source: R/class_trial_comparison.R

fetch.TrialComparisonR Documentation

Fetch Objects from a Trial Comparison

Description

Extracts contained objects by name or position without modifying the comparison or copying its objects. A single selection returns the object itself by default.

Usage

## S3 method for class 'TrialComparison'
fetch(x, ..., output = c("value", "named", "labeled", "list"))

Arguments

x

A TrialComparison.

...

Object names or integer positions, including vectors and multiple selections. Names may be quoted or unquoted. Positive positions count from the beginning and negative positions from the end. With no selection, the last object is returned. Quasi-quotation and programmatic selectors are supported; an unquoted name matching a contained object takes precedence over a variable of the same name in the calling environment.

output

One of "value" (default), "named", "labeled", or "list". "value" returns a single selected object directly and multiple selections as a named list. The other modes always return a named list. Collection labels are the supplied object names, with positions for unnamed objects; consequently "labeled" and "named" are equivalent for comparisons.

Details

fetch(x, "fixed"), fetch(x, fixed) and fetch(x, 1) provide the named and positional object access supported by [[. Only contained objects are selected; R6 members are never returned as a fallback. Numeric positions must be finite, nonzero integers within the collection bounds. Selecting the last object of an empty comparison raises an index error.

Value

A contained object by reference or a list of objects. An unknown name returns NULL (retained as a NULL entry in list output). Empty selector vectors return an empty list.

See Also

fetch() and getComparison().

Examples

comparison <- getComparison(
    fixed = getDesignFixed(),
    sequential = getDesignGroupSequential(kMax = 2)
)
identical(comparison |> fetch("fixed"), comparison[["fixed"]])
identical(comparison |> fetch(fixed), comparison$fixed)
identical(comparison |> fetch(1), comparison[[1]])
comparison |> fetch(-1)
comparison |> fetch(1:2, output = "list")


rpact documentation built on Nov. 17, 2026, 1:07 a.m.