I need branching for my target pipeline (at least I think so)
My definition for the target pipeline looks as follows:
list(
# ILK
tar_target(ilk_file, file.path(".", "input", "file_1.csv"), format = "file"),
tar_target(ilk_bibliography, bibliography_metrics(ilk_file, mc.cores = 1)),
tar_target(ilk_metrics, dois_measures(ilk_bibliography)),
tar_target(plot_pub_year_ilk, plot_publication_year(ilk_bibliography)),
tar_target(plot_oa_status_ilk, plot_oa_status(ilk_bibliography)),
tar_target(plot_top_journals_data_ilk, plot_top_journals_data(ilk_bibliography)),
tar_target(plot_top_journals_ilk, plot_top_journals(plot_top_journals_data_ilk)),
tar_target(plot_top_country_data_ilk, plot_top_country_data(ilk_bibliography)),
tar_target(plot_top_country_ilk, plot_top_country(plot_top_country_data_ilk)),
tar_quarto(
report,
"bibliography_report.qmd",
execute_params = ias_parameter,
quiet = FALSE
)
)
Now I want to run this pipeline for several input files (initially 4) and new ones will be added over time.
If I understand branching correctly (https://books.ropensci.org/targets/dynamic.html) dynamic branching with the map()
pattern is the way to go. But I am at a loss how I can implement this?
To complicate things, the quarto document depends on the output from all previous targets mentioned, but not the ones based on other files, so it has e.g. tar_read(plot_oa_status_ilk)
in it.
I am at a loss here – how can I achieve this without repeating the same code block again and again?