R not able to find a sourced function

60 views Asked by At

I am using doParallel and foreach packages for running my code on multiple cores. My code is something like

fun1 <- function(param1, param2, param3)
{
   do something
   fun2(param4, param5, param6)

   foreach(param4 = 1:length(param1) %dopar% fun2(param4, param5, param6)
   return something
}

fun2 <- function(param4, param5, param6)
{
   do something
   fun3(param7, param8, param9)
   return something
}

fun3 <- function(param7, param8, param9)
{
   do something
   fun4(param10, param11, param12)
   return something
}

fun4 <- function(param10, param11, param12)
{
   do something

   return something
}

Call: fun1(a,b,c)

When I call fun1, the first instance of fun2 is executed successfully, but the instance where I am calling fun2 with foreach gives an error Error in fun2(param4, param5, : task 1 failed - "could not find function "fun2""

0

There are 0 answers