This example in "R for Data Science" uses invoke_map
which is now retired.
sim <- tribble(
~f, ~params,
"runif", list(min = -1, max = 1),
"rnorm", list(sd = 5),
"rpois", list(lambda = 10)
)
sim %>%
mutate(sim = invoke_map(f, params, n = 10))
If I extract the columns separately then it works with map2
and exec
map2(sim$f, sim$params, function(fn, args) exec(fn, !!!args, n = 10))
However, I cannot get mutate
to work with map2
and exec
sim %>%
mutate(sim = map2(f, params, function(fn, args) exec(fn, !!!args, n = 10)))
I get the error "Error: Can't splice an object of type closure because it is not a vector"
Can anyone help with this?