Skip to contents

Converts a rap_object or a pipeline expression into a ready-to-use _targets.R file. The generated script uses targets::tar_target() with optional dynamic branching over UFs, years, or their Cartesian product.

Usage

sus_rap_targets(
  pipeline,
  file_path = "_targets.R",
  branching = c("none", "uf", "year", "cross"),
  workers = 1L,
  include_qc = TRUE,
  lang = "pt",
  overwrite = FALSE
)

Arguments

pipeline

A rap_object (from sus_rap_read()) or a quoted pipeline expression (from quote()).

file_path

character(1) - Output path. Default "_targets.R".

branching

character(1) - Branching strategy: "none" (default), "uf", "year", or "cross".

workers

integer(1) - Number of parallel workers. Default 1.

include_qc

logical(1) - Add a quality-control target. Default TRUE.

lang

character(1) - Language for messages.

overwrite

logical(1) - Overwrite existing file. Default FALSE.

Value

Invisibly, the path of the generated _targets.R file.

Branching strategies

"none"

Single analysis, no branching.

"uf"

One branch per UF - ideal for multi-state comparisons.

"year"

One branch per year.

"cross"

All UF-year combinations via tidyr::crossing().

Examples

if (FALSE) { # \dontrun{
rap <- sus_rap_read("pipeline_sp.R")
sus_rap_targets(rap, "_targets.R", branching = "uf", workers = 4)
# then run: targets::tar_make()
} # }