% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tar_init.R
\name{tar_init}
\alias{tar_init}
\title{Initialize a targets project}
\usage{
tar_init(
  home,
  phase_names,
  phase_nums = seq_along(phase_names),
  separate_phase_scripts = TRUE,
  phase_subdirs = c("src", "out"),
  use_leading_zeros = FALSE,
  overwrite = FALSE
)
}
\arguments{
\item{home}{chr, root directory of targets project. To use the current
working directory, use  \code{"."}.}

\item{phase_names}{chr vector, names of target phases like "fetch",
"process", etc.}

\item{phase_nums}{int vector, numbers to prepend to phase_names like
\code{"1_fetch"}, \code{"2_process"}, etc. Defaults to
seq_along(phase_names)}

\item{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}

\item{phase_subdirs}{chr vector, subdirectories within each phase. Defaults
to "src", "out"}

\item{use_leading_zeros}{lgl, should "0" be used in front of phase numbers in
file and directory names?}

\item{overwrite}{lgl, should the initialization overwrite files and folders
that already exist? Defaults to FALSE}
}
\value{
\code{NULL} invisibly
}
\description{
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. For more information,
internal USGS employees can look at section 12 of Targets 2 training
course.
}
\examples{
# 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)$")

# clean out tmp folder
unlink(tmp, recursive = TRUE, force = TRUE)
dir.create(tmp)

}
