knitr::opts_chunk$set( warning = FALSE, message = FALSE, collapse = TRUE, comment = "#>" )
Decompose and Recompose Functions
remotes::install_github("sckott/astr")
library("astr")
a simple function
foo <- function(x) { x + 1 } foo(5)
decompose the function
df <- ast_decompose(foo) df class(df)
modify an aspect of the function
out <- ast_modify(df, from = "+", to = "-") out
ast_recompose(out) ex <- ast_recompose(out, as_expr = TRUE) eval(ex)(5)
astr
in R doing citation(package = 'astr')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.