Like tar_target_date() but adds an age-based cue via
tarchetypes::tar_cue_age_raw() so the target automatically re-runs after
a configurable time period. Useful for targets that fetch data from APIs.
Usage
tar_age_date(name, command, age = as.difftime(1, units = "days"), ...)Arguments
- name
Symbol, name of the target.
- command
Expression, R command to run the target.
- age
A difftime object specifying the maximum age before the target re-runs. Defaults to 1 day.
- ...
Additional arguments passed to
targets::tar_target_raw().
Value
A list of two target objects: the primary target (with an age cue)
and the companion _date target.
Examples
if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) {
targets::tar_dir({
targets::tar_script({
library(targets)
list(
epitargets::tar_age_date(x, 1 + 1, age = as.difftime(1, units = "days"))
)
})
targets::tar_make()
targets::tar_read(x)
targets::tar_read(x_date)
})
}