Skip to contents

Declaration vocabulary of the rule dialect, without the r8_ prefix of operations on values. In a rule, val(expr) is the value of the R expression expr, evaluated once, when rule() runs, in the environment that calls rule(); a bare name in a rule is a field or a column. The value is stored in the rule as a literal: one non-NA logical, integer, double, string, Date, or POSIXct, or a vector of them as the right operand of %in%. In a declaration of a package, the value is the one the expression has when the package is installed.

Usage

val(x)

Arguments

x

The value.

Value

x.

Details

Outside a rule, val(x) returns x.

Examples

max_cost <- 100
rule(cost <= val(max_cost), message = "cost is at most max_cost.")
#> <r8 rule> cost <= 100
#>   cost is at most max_cost.
allowed <- c("linear", "rbf")
rule(kernel %in% val(allowed), message = "kernel is linear or rbf.")
#> <r8 rule> kernel %in% c("linear", "rbf")
#>   kernel is linear or rbf.