-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rmarkdown::render with transform #866
Labels
Comments
library(drake)
plan <- drake_plan(
y = target(
f(x),
transform = cross(f = c(a, b), x = c(1, 2))
),
report = target(
rmarkdown::render(
knitr_in(!!paste0(.id_chr, ".Rmd")),
file_out(!!paste0(.id_chr, ".html"))
),
transform = map(y)
)
)
print(plan)
#> # A tibble: 8 x 2
#> target command
#> <chr> <expr>
#> 1 y_a_1 a(1) …
#> 2 y_b_1 b(1) …
#> 3 y_a_2 a(2) …
#> 4 y_b_2 b(2) …
#> 5 report_y_a… rmarkdown::render(knitr_in("report_y_a_1.Rmd"), file_out("re…
#> 6 report_y_b… rmarkdown::render(knitr_in("report_y_b_1.Rmd"), file_out("re…
#> 7 report_y_a… rmarkdown::render(knitr_in("report_y_a_2.Rmd"), file_out("re…
#> 8 report_y_b… rmarkdown::render(knitr_in("report_y_b_2.Rmd"), file_out("re…
# Just for the sake of the reprex:
files <- paste0(plan$target[5:8], ".Rmd")
tmp <- file.create(files)
config <- drake_config(plan)
vis_drake_graph(config) Created on 2019-05-13 by the reprex package (v0.2.1) Alternatively, you can use library(drake)
plan <- drake_plan(
y = target(
f(x),
transform = cross(f = c(a, b), x = c(1, 2))
),
report = target(
rmarkdown::render(
knitr_in(!!paste0(deparse(substitute(y)), ".Rmd")),
file_out(!!paste0(deparse(substitute(y)), ".html"))
),
transform = map(y)
)
)
print(plan)
#> # A tibble: 8 x 2
#> target command
#> <chr> <expr>
#> 1 y_a_1 a(1) …
#> 2 y_b_1 b(1) …
#> 3 y_a_2 a(2) …
#> 4 y_b_2 b(2) …
#> 5 report_y_a_1 rmarkdown::render(knitr_in("y_a_1.Rmd"), file_out("y_a_1.ht…
#> 6 report_y_b_1 rmarkdown::render(knitr_in("y_b_1.Rmd"), file_out("y_b_1.ht…
#> 7 report_y_a_2 rmarkdown::render(knitr_in("y_a_2.Rmd"), file_out("y_a_2.ht…
#> 8 report_y_b_2 rmarkdown::render(knitr_in("y_b_2.Rmd"), file_out("y_b_2.ht…
# Just for the sake of the reprex:
files <- paste0(plan$target[1:4], ".Rmd")
tmp <- file.create(files)
config <- drake_config(plan)
vis_drake_graph(config) Created on 2019-05-13 by the reprex package (v0.2.1) |
And as of a9bbcc3, you can use library(drake)
plan <- drake_plan(
y = target(
f(x),
transform = cross(f = c(a, b), x = c(1, 2))
),
report = target(
rmarkdown::render(
knitr_in(!!paste0(.id_chr, ".Rmd")),
file_out(!!paste0(.id_chr, ".html"))
),
transform = combine(y, .by = f)
)
)
plan
#> # A tibble: 6 x 2
#> target command
#> <chr> <expr>
#> 1 y_a_1 a(1) …
#> 2 y_b_1 b(1) …
#> 3 y_a_2 a(2) …
#> 4 y_b_2 b(2) …
#> 5 report_a rmarkdown::render(knitr_in("report_a.Rmd"), file_out("report_a.…
#> 6 report_b rmarkdown::render(knitr_in("report_b.Rmd"), file_out("report_b.…
tmp <- file.create(c("report_a.Rmd", "report_b.Rmd"))
config <- drake_config(plan)
vis_drake_graph(config) Created on 2019-05-13 by the reprex package (v0.2.1) |
Thanks for the fast response and fix! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to apply transform to
rmarkdown::render
? Something like below for example:My scenario is that each of the previous crossed targets has enough information to render its own report, preferably named after its own target's name.
I will have a summary report as well at the end, but in this case a drilled-down report for each target would be useful too.
The text was updated successfully, but these errors were encountered: