View source: R/ast_recompose.R
ast_recompose | R Documentation |
Recompose an R function
ast_recompose(x, as_expr = FALSE)
x |
an object of class |
as_expr |
(logical) return the function as an expression?
default: |
a function as a character string, or an expression if
as_expr=TRUE
foo <- function(x) {
x + 1
}
foo(5)
# decompose the function
df <- ast_decompose(foo)
df
# recompose the function
fun <- ast_recompose(df)
fun
parse(text = fun)
eval(parse(text = fun))
eval(parse(text = fun))(5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.