gpt4 book ai didi

drake-r-package - 创建目标组

转载 作者:行者123 更新时间:2023-12-04 10:59:47 26 4
gpt4 key购买 nike

假设我有以下计划:

test_plan = drake_plan(
foo = target(x + 1, transform = map(x = c(5, 10))),
bar = 42
)

现在我想创建一个包含两个子目标 foo_5、foo_10 和目标栏的新目标。我怎样才能做到这一点?我觉得它一定非常简单,但我无法找到解决方案。

谢谢!

最佳答案

是的,这既可能又简单。内置的解决方案是使用标签:https://books.ropensci.org/drake/static.html#tags .例子:

library(drake)
drake_plan(
foo = target(
x + 1,
transform = map(x = c(5, 10), .tag_out = group)
),
bar = target(
42,
# You need a transform to use a tag, even for 1 target.
transform = map(tmp = 1, .tag_out = group)
),
baz_map = target(group, transform = map(group)),
baz_combine = target(c(group), transform = combine(group))
)
#> # A tibble: 7 x 2
#> target command
#> <chr> <expr>
#> 1 foo_5 5 + 1
#> 2 foo_10 10 + 1
#> 3 bar_1 42
#> 4 baz_map_foo_5 foo_5
#> 5 baz_map_foo_10 foo_10
#> 6 baz_map_bar_1 bar_1
#> 7 baz_combine c(foo_5, foo_10, bar_1)

创建于 2019-11-16 由 reprex package (v0.3.0)

关于drake-r-package - 创建目标组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58894812/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com