When I try to use future_apply
with plan(multisession)
, it says that the package I'm trying to use doesn't exist. When I use plan(sequential)
it works fine. I also get the same error when using plan(callr)
.
Here's the error:
Error in loadNamespace(name): there is no package called 'fuzzyjoin'
Can anyone help me figure out a solution or what's going wrong here?
I'm not sure if this is related to the future.apply package or future or globals packages as I know that they are also involved here.
Here's my code showing the issue:
library(fuzzyjoin)
library(future.apply)
#> Loading required package: future
library(dplyr)
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyr)
iris_mod<- iris %>%
mutate(examplefield= Sepal.Width + Petal.Length,
Species = as.character(Species))
iristype <- iris_mod$Species %>% unique()
plan(sequential)
test_sequential <- future_lapply(iristype,
FUN = function(x) {
fuzzyjoin::fuzzy_left_join(
iris_mod %>% filter(Species %in% x),
iris_mod,
by = c("Species"="Species",
"examplefield"="Sepal.Length"),
match_fun = list(`==`, `<`)
)},
future.chunk.size= 2
)
plan(multisession)
test_multisession <- future_lapply(iristype,
FUN = function(x) {
fuzzyjoin::fuzzy_left_join(
iris_mod %>% filter(Species %in% x),
iris_mod,
by = c("Species"="Species",
"examplefield"="Sepal.Length"),
match_fun = list(`==`, `<`)
)},
future.chunk.size=2
)
#> Error in loadNamespace(name): there is no package called 'fuzzyjoin'
Created on 2022-01-28 by the reprex package (v2.0.1)
I'm running R v4.0.3 if that's relevant.