# Degenerate formulas are often created by quoting, since `~`
# records the environment when it is evaluated the first time:
f <- ~~expr
# The outer formula has been evaluated and is a tidy quote:
is_tidy_quote(f)
# But the inner formula is not:
inner_f <- f_rhs(f)
is_tidy_quote(inner_f)
# You can use as_tidy_quote() to add the environment information:
as_tidy_quote(inner_f, base_env())
# Or turn expressions or any R object in a tidy quote:
as_tidy_quote(quote(expr), env())
as_tidy_quote(10L, env())
Run the code above in your browser using DataLab