| bm_expr | R Documentation |
Constructs an expression mapping
bm_expr(
expr,
assume = character(0),
labels = NULL,
.envir = rlang::caller_env()
)
expr |
An expression object, typically created using |
assume |
character vector listing valid assumptions for the
combination of the expression and data, derived variables, and root
variables. This can be used to specify assumptions that allow for more
efficient Jacobian calculations. For example, if the expression
is row-wise in the data and derived variables, then
|
labels |
list of |
.envir |
The environment for the expression evaluation. By default, this is set to the caller environment. |
The input is currently ignored.
data should be a list with data objects, with the main object called
data.
If is_rowwise == TRUE, the number of rows in the data data.frame
determines the number of rows in the output, and the columns can be used as
constants in the expression, accessed via .data$colname,
.data.$colname, or .data.[["colname"]].
A bm_expr mapper object
bru_mapper, bru_mapper_generics
Other mappers:
bm_aggregate(),
bm_collect(),
bm_const(),
bm_factor(),
bm_fm_mesh_1d,
bm_fmesher(),
bm_harmonics(),
bm_index(),
bm_linear(),
bm_logitaverage(),
bm_logsumexp(),
bm_marginal(),
bm_matrix(),
bm_multi(),
bm_pipe(),
bm_reparam(),
bm_repeat(),
bm_scale(),
bm_shift(),
bm_sum(),
bm_taylor(),
bru_get_mapper(),
bru_mapper()
# Basic expression with only root variables ("x").
(m <- bm_expr(rlang::quo(cos(x))))
ibm_eval(m, list(), list(x = 1:5))
ibm_eval2(m, list(), list(x = 1:5))
# Expression with data
(m <- bm_expr(rlang::quo(cos(x) * .data$z)))
the_data <- list(data = data.frame(z = 11:15))
ibm_eval(m, list(), list(x = 1:5), data = the_data)
ibm_eval2(m, list(), list(x = 1:5), data = the_data)
# Expression with data, root variables, and derived variables.
(m <- bm_expr(
rlang::quo(sin(x_latent) + cos(.effect$y) * .data$z),
labels = list(root = "latent", derived = "effect", suffix = "_latent")
)
)
ibm_eval(
m,
list(),
derived = list(y = 2:6), # y = x + 1
jacobians = list(y = list(x = Matrix::Diagonal(1.0, 5))),
data = the_data,
state = list(x = 1:5)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.