spawn_env = function(f, ...){
argdt <- do.call(data.table::CJ, rlang::dots(...))
fenv <- apply(argdt, 1, function(i){
rlang::f_env(f) <- rlang::env_new(parent = rlang::env_base(), dict = i)
return(f)
})
return(fenv)
}
varToDT <- function(vars, env_list){
do.call(cbind, lapply(vars, function(k){
adt <- data.table(sapply(env_list, function(i) rlang::env_get(i, k)))
setnames(adt, k)
return(adt)
}))
}
form_list <- rlang::parse_exprs_f(c("a+2*b; c*a+3*b+c; a+a^2"))
eval_list <- lapply(formula_list, function(i) spawn_env(i, a = 1:10, b = 2:3, c=1:7))
pf <- pryr::f
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.