Hi,
I would like to create a personal function for parallel tasks. I would like to use future (MAC OS) to make tasks faster, but it doesn't get the command from ... in a function. I enclose a sample.
Thank you for your answer in advance,
M
library(tidyverse)
ftest <- function(x, ...) {
library(furrr)
plan(multisession, workers = 2)
future_map(x, .f = ~ mutate(.x, ...))
}
iris %>%
group_by(Species) %>%
group_map(~ .) %>% # split to 3 frames = list
ftest(s = Sepal.Length + Sepal.Width)
gtest <- function(x, ...) {
library(furrr)
plan(multisession, workers = 2)
x %>%
nest() %>%
mutate(future_map(data, ~ mutate(., ...)))
}
iris %>%
group_by(Species) %>%
gtest(s = Sepal.Length + Sepal.Width)