-
Notifications
You must be signed in to change notification settings - Fork 38
Fails to find extraneous package functions when passed a function in a list #92
Copy link
Copy link
Closed
Description
OS: Windows 10
R 3.6.1
furrr: 0.1.0.9002
future: 1.15.1
Putting a function into a list and then passing it into future_map apparently causes it to not find functions appropriately.
library(extraDistr)
suppressPackageStartupMessages(library(purrr))
suppressPackageStartupMessages(library(furrr))
plan(multiprocess)
# Innermost function which uses something from a package
inner_fun <- function() rbern(10, 0.5) # from extraDistr
# A function that calls another which is passed to it in a list
wrapper_fun <- function(fun_list) {
fun_list$sim_fun()
}
# A list of functions
list_of_funs <- list(sim_fun = inner_fun)
# Will work
map(
1:2,
function(i) wrapper_fun(list_of_funs)
)
#> [[1]]
#> [1] 1 0 0 1 0 0 1 0 0 0
#>
#> [[2]]
#> [1] 1 1 0 1 0 0 0 0 1 0
# Will fail to find rbern
future_map(
1:2,
function(i) wrapper_fun(list_of_funs)
)
#> Error in rbern(10, 0.5): could not find function "rbern"Created on 2019-11-27 by the reprex package (v0.3.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels