有没有办法可以在子包的“library()”中使用“exclude”参数?

问题描述 投票:0回答:1

我不断遇到这个问题,其中

purrr::invoke
掩盖了
sparklyr::invoke
。它会导致很多
{sparklyr}
功能无法工作。

我可以用

invoke <- sparklyr::invoke
修复它,但这看起来像是一个黑客。有没有办法在
exclude
中使用
library()
参数来代替?

这两个我都试过了,都没有用。

library(tidyverse, exclude = "invoke")
#> Warning in rm(list = exclude, envir = env): object 'invoke' not found
invoke
#> function (.f, .x = NULL, ..., .env = NULL) 
#> {
#>     lifecycle::deprecate_soft("1.0.0", "invoke()", "exec()")
#>     .env <- .env %||% parent.frame()
#>     args <- c(as.list(.x), list(...))
#>     do.call(.f, args, envir = .env)
#> }
#> <bytecode: 0x000001a77b6339f0>
#> <environment: namespace:purrr>
library(tidyverse, exclude = "purrr::invoke")
#> Warning in rm(list = exclude, envir = env): object 'purrr::invoke' not found
invoke
#> function (.f, .x = NULL, ..., .env = NULL) 
#> {
#>     lifecycle::deprecate_soft("1.0.0", "invoke()", "exec()")
#>     .env <- .env %||% parent.frame()
#>     args <- c(as.list(.x), list(...))
#>     do.call(.f, args, envir = .env)
#> }
#> <bytecode: 0x000001c03be31e78>
#> <environment: namespace:purrr>
r tidyverse sparklyr
1个回答
0
投票

就我个人而言,我更喜欢将

library
与各个软件包一起使用,而不是与 tidyverse 一起使用,在这种情况下,使用
exclude=
没有问题,但如果您无论如何都想使用 tidyverse,请这样做:

library(purrr, exclude = "invoke")
library(tidyverse)

# test
invoke
## Error: object 'invoke' not found
© www.soinside.com 2019 - 2024. All rights reserved.