Aliases: is_formula is_bare_formula
Keywords:
### ** Examples is_formula(~10)
[1] TRUE
is_formula(10)
[1] FALSE
# If you don't supply `lhs`, both one-sided and two-sided formulas # will return `TRUE` is_formula(disp ~ am)
[1] TRUE
is_formula(~am)
[1] TRUE
# You can also specify whether you expect a LHS: is_formula(disp ~ am, lhs = TRUE)
[1] TRUE
is_formula(disp ~ am, lhs = FALSE)
[1] FALSE
is_formula(~am, lhs = TRUE)
[1] FALSE
is_formula(~am, lhs = FALSE)
[1] TRUE
# Handling of unevaluated formulas is a bit tricky. These formulas # are special because they don't inherit from `"formula"` and they # don't carry an environment (they are not scoped): f <- quote(~foo) f_env(f)
NULL
# By default unevaluated formulas are treated as formulas is_formula(f)
[1] TRUE
# Supply `scoped = TRUE` to ensure you have an evaluated formula is_formula(f, scoped = TRUE)
[1] FALSE
# By default unevaluated formulas not treated as bare formulas is_bare_formula(f)
[1] FALSE
# If you supply `scoped = TRUE`, they will be considered bare # formulas even though they don't inherit from `"formula"` is_bare_formula(f, scoped = TRUE)
[1] FALSE