Skip to contents

The facts of one field of a struct, a struct variant, or a table. A bare field type is the short form of field(type).

Usage

field(
  type,
  default = NULL,
  description = "",
  sensitive = FALSE,
  unit = NULL,
  compute = NULL,
  context = FALSE,
  extensions = NULL
)

Arguments

type

An r8_field_type or an R8 type: The field's type.

default

Optional: The default value, used when the field is absent.

description

Character: What the field holds.

sensitive

Logical: Mask the value in printing, events, errors, and differences.

unit

Optional Character: A unit code, by convention UCUM, such as "mg".

compute

Optional r8_calc: For a field of type option(), its value as an expression over the other fields, a calc(), which r8resolve() fills.

context

Logical: For a field of type option(), r8resolve(x, context) fills the value from context. At most one of compute and context is given.

extensions

Optional named list: Namespaced extensions, such as list("rtemis:tunable" = TRUE), which R8 stores and does not interpret.

Value

An r8_field.

Examples

field(type_double(exclusive_min = 0), default = 1, description = "Cost.")
#> <r8 field> double (0, Inf) = 1
#>   Cost.
field(option(type_double()), compute = calc(dose_mg / 1000))
#> <r8 field> optional double
#>   computed: dose_mg/1000
field(option(type_integer(min = 1L)), context = TRUE)
#> <r8 field> optional integer [1, Inf)
#>   filled from the context