我创建了一个包来使用 {drake} 为分析工作流组织我的文件。一个函数创建 Drake 计划。调用此函数_drake.R
以运行分析r_make()
。到目前为止一切正常,我可以更改函数参数中的一些路径和参数,它会创建一个新的运行计划。
这是一个示例代码
library(drake)
library(readr)
test_fn_plan <- function(paths, countries) {
drake_plan(
data = target(
read_tsv(file_in(path)),
transform = map(path = !!paths, country = !!countries, .id = country)
)
)
}
test_fn_plan(
c("path/to/data_IE.tsv", "path/to/data_UK.tsv"),
c("Ireland", "United Kingdom")
)
#> # A tibble: 2 x 2
#> target command
#> <chr> <expr>
#> 1 data_Ireland read_tsv(file_in("path/to/data_IE.tsv"))
#> 2 data_United.Kingdom read_tsv(file_in("path/to/data_UK.tsv"))
由reprex 包(v0.3.0)于 2019 年 10 月 29 日创建
问题来自devtools::check()
. 计划步骤被认为是全局变量,未定义的全局变量,我不知道如何处理它们。
我收到以下警告(我的实际代码有几十个)
test_fn_plan: no visible binding for global variable ‘path’
test_fn_plan: no visible binding for global variable ‘country’
我已经用 rlang 的.data$
代词修复了所有其他未定义的全局变量。我留下了这些警告,我不知道该怎么办(除了忍受它)。