formula_utils | R Documentation |
Tools to create R formulas
g3_formula(code, ...)
code |
Unevaluated code to be turned into a formula |
... |
Named items to add to the formula's environment, or a single list / environment to use. |
When using ~
, the local environment is attached to the code.
This can leak unwanted variables into a model. This allows you to avoid
the problem without resorting to local.
A formula object, with environment created from .... Can then be used anywhere in gadget3 that accepts a formula.
# g3_formula is identical to defining a formula within local():
stopifnot(all.equal(
g3_formula(x + 1, z = 44),
local({ z = 44; ~x + 1 })
))
# If the code is destined for CRAN, you need to quote() to avoid check errors:
stopifnot(all.equal(
g3_formula(quote( x + 1 ), z = 44),
local({ z = 44; ~x + 1 })
))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.