as_closure | R Documentation |
as_closure()
is like as_function()
but also wraps primitive
functions inside closures. Some special control flow primitives
like if
, for
, or break
can't be wrapped and will cause an
error.
as_closure(x, env = caller_env())
x |
A function or formula. If a function, it is used as is. If a formula, e.g. If a string, the function is looked up in |
env |
Environment in which to fetch the function in case |
# Primitive functions are regularised as closures
as_closure(list)
as_closure("list")
# Operators have `.x` and `.y` as arguments, just like lambda
# functions created with the formula syntax:
as_closure(`+`)
as_closure(`~`)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.