Run this function in a new targets project directory. It will create R files and directories using the targets project structure often used by the USGS Data Science Community of Practice. Ror more information, internal USGS employees can look at section 12 of Targets 2 training course.
Arguments
- phase_names
chr vector, names of target phases like "fetch", "process", etc.
- phase_nums
int vector, numbers to prepend to phase_names like
"1_fetch","2_process", etc. Defaults to seq_along(phase_names)- home
chr, root directory of targets project. Defaults to current working directory "."
- separate_phase_scripts
lgl, should a different R script be created for each phase like "1_fetch.R", "2_process.R", etc? If FALSE, then targets lists will be initialized in _targets.R file. Defaults to TRUE
- phase_subdirs
chr vector, subdirectories within each phase. Defaults to "src", "out"
- use_leading_zeros
lgl, should "0" be used in front of phase numbers in file and directory names?
- overwrite
lgl, should the initialization overwrite files and folders that already exist? Defaults to FALSE
Examples
if (FALSE) { # \dontrun{
# temporary directories in which targets project is initialized (you can skip
# this part if creating your own project)
tmp <- tempdir()
unlink(tmp, recursive = TRUE, force = TRUE)
dir.create(tmp)
# creates 1_fetch, 2_process, 3_summarize R scripts and directories
tar_init(home = tmp, phase_names = c("fetch", "process", "summarize"))
list.files(tmp, full.names = FALSE, recursive = TRUE, all.files = TRUE,
pattern = "\\.(R|empty)$")
# clean out tmp folder
unlink(tmp, recursive = TRUE, force = TRUE)
dir.create(tmp)
# different structure starting with 0_config and including "in/" dir in each phase
tar_init(home = tmp,
phase_names = c("config", "pull", "munge", "visualize"),
phase_nums = 0:3,
phase_subdirs = c("in", "src", "out"),
separate_phase_scripts = FALSE)
list.files(tmp, full.names = FALSE, recursive = TRUE, all.files = TRUE,
pattern = "\\.(R|empty)$")
} # }