bru_eval_in_data_context: Evaluate expressions in data contexts

View source: R/bru.inference.R

bru_eval_in_data_contextR Documentation

Evaluate expressions in data contexts

Description

Evaluate an expression in a series of data contexts, also making the objects directly available as names surrounded by ".", stopping when the expression evaluation completes with no error.

This is an internal inlabru method, not intended for general use.

Usage

bru_eval_in_data_context(
  input,
  data = NULL,
  default = NULL,
  .envir = parent.frame()
)

Arguments

input

An expression to be evaluated

data

list of data objects in priority order. Named elements will be available as .name. in the evaluation. The input expression is evaluated with each non-NULL data object as envir, in order, until success. If there are no non-NULL data objects, the expression is evaluated in an empty environment, potentially falling back to enclosing environment variables.

default

Value used if the expression is evaluated as NULL. Default NULL

.envir

The evaluation environment

Value

The result of expression evaluation

Examples

# The A values come from the 'data' element, and the B values come from
# the 'response_data' element, as that is listed first.
bru_eval_in_data_context(
  quote(
    list(A = .data.$x, B = x)
  ),
  list(
    response_data = tibble::tibble(x = 1:5),
    data = tibble::tibble(x = 1:10)
  )
)
# Both A and B come from the 'data' element, as 'x' is found there,
# terminating the evaluation attempt.
bru_eval_in_data_context(
  quote(
    list(A = .data.$x, B = x)
  ),
  list(
    data = tibble::tibble(x = 1:10),
    response_data = tibble::tibble(x = 1:5)
  )
)


fbachl/inlabru documentation built on June 12, 2025, 2:09 p.m.