I am trying to run an R loop in parallel with foreach. The idea is that the function called with foreach will take a certain function from a list and use that as a parameter for yet another function.
func_list <- c(a(), b(), c())
loop_func <- function(letter){
obj <- f(parameter = letter)
return(c(letter, obj)
foreach(val=func_list, .combine='rbind') %dopar% {
loop_func(val)
} -> result
So I am trying to make the loop_func return an output (obj in this case), as well as what function it used as a parameter for the f() function. However, I can not seem to get that function as a string.
I tried as.character(substitute(letter))
, but that gave me "val".
Is there an intuitive way to get:
"a" obj
returned from the function?