
Check that a model formula uses only data columns and brms term syntax
Source:R/utils-safe-code.R
is_safe_formula.RdFormula text typed into the app reaches brms and model.frame(), which
evaluate calls such as I(q()). This check accepts data columns, the
constants 0 and 1, the operators ~ + : * | || / - (, and the brms
helpers ar() (named time, gr, cov arguments), gr(),
trials(), and the exposure offset offset(log(<column>)); every other
function call, string, $, @, or :: is rejected.
Examples
is_safe_formula("y ~ level_AB + (1 | case)", c("y", "level_AB", "case"))
#> [1] TRUE
is_safe_formula("y ~ I(q())", "y")
#> [1] FALSE