Suppose I have a toy df with a column of unique functions (fun) like so:
df_1 <- tibble(values = rep(2,3), exponent = 1:3) %>%
mutate(fun = map(.x = exponent, .f = function(exponent) { function(x){}})) # creating an closure "fun"
and further, that I have a list of dfs, with the list having the same # of elements as df_1:
list_o_dfs <- list(tibble(var = 1:10), tibble(var = 3:5), tibble(var = rep(2,5)))
What I want to do: map the fun column of functions in df_1 to var in each tibble of list_o_dfs to create a new column
here's a sketch of how I'm thinking about the syntax, which doesn't work:
list_o_dfs %>% enframe() %>% mutate(new_var = map(.x = var, .f = df_1$fun))
It feels like pmap may be the solution here, possibly after enframe-ing/nesting list_o_dfs, and then binding columns to make one nested df, but that isn't immediately obvious to me and attempts have likewise failed.
Any advice is much appreciated.