当我尝试使用future_apply
with 时plan(multisession)
,它说我尝试使用的包不存在。当我使用它时plan(sequential)
,它工作正常。使用时我也遇到同样的错误plan(callr)
。
这是错误:
Error in loadNamespace(name): there is no package called 'fuzzyjoin'
谁能帮我找出解决方案或这里出了什么问题?
我不确定这是否与 future.apply 包或 future 或 globals 包有关,因为我知道它们也参与其中。
这是我的代码显示问题:
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'
由reprex 包于 2022-01-28 创建(v2.0.1)
如果相关,我正在运行 R v4.0.3。