0

I am trying to replace purrr::map with furrr:future_map to run linear regressions on a list of permuted dataframes but I get the following error:

Error in as.data.frame.default(data) : 
  cannot coerce class ‘"permutation"’ to a data.frame

Here's my code:

library(plyr); library(dplyr); library(modelr); library(purrr); library(furrr)

# specify regression formula
reg_form <- 'mpg ~ cyl + disp + hp + wt'

plan(multisession, workers = 4)

# Random permutations of 'hp'
perm_data <- permute(mtcars, 5000, 'hp')

# permuted linear regressions with map
perm_models <- map(perm_data$perm, ~ lm(reg_form, data = .))

# permuted linear regressions with future_map
perm_models_parallel <- future_map(perm_data$perm, ~ lm(reg_form, data = .))

I have read through the furrr page but I can't figure out if the gotchas they have described apply to my problem here: https://furrr.futureverse.org/articles/gotchas.html

boleneuro
  • 23
  • 4

0 Answers0