I need to run a function that is in .GlobalEnv in a parallel processing using the multidplyr package.
Using a simple example and no parallel processing works as expected:
library(dplyr)
library(purrr)
library(multidplyr)
data.frame(x = 1:10) %>%
mutate(y = purrr::map(x, add_a))
But when I try to put the parallelism, it does not recognize the function "add_a"
add_a <- function(x) {
paste0(x, "A")
}
data.frame(x = 1:10) %>%
partition() %>%
mutate(
y = purrr::map(x, add_a)
)
Returning the following message:
Error in checkForRemoteErrors(lapply(cl, recvResult)) :
10 nodes produced errors; first error: objeto 'add_a' não encontrado