A convenience wrapper around tarchetypes::tar_file_read() for CSV files.
Creates a pair of targets: one to track the file with format = "file",
and another to read the file with readr::read_csv().
Usage
tar_csv_read(name, command, .read_csv_args = list(show_col_types = FALSE), ...)Arguments
- name
Symbol, name of the target.
- command
Expression, R code that returns the file path to the CSV.
- .read_csv_args
A named list of additional arguments passed to
readr::read_csv(). Defaults tolist(show_col_types = FALSE). Supplying this argument replaces the defaults entirely.- ...
Additional arguments passed to
targets::tar_target_raw()for the read target.
Value
A list of two target objects: a file-tracking target
(name_file) and a CSV-reading target (name).
Details
The storage format of the read target is inherited from
targets::tar_option_get("format") (by default "rds"). Callers can
override it by passing e.g. format = "qs" via ....
Examples
if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) {
targets::tar_dir({
targets::tar_script({
library(targets)
list(
epitargets::tar_csv_read(my_data, "data.csv")
)
})
targets::tar_manifest()
})
}
