% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/drake_plan_helpers.R
\name{drake_envir}
\alias{drake_envir}
\title{Get the environment where drake builds targets
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#questioning}{\figure{lifecycle-questioning.svg}{options: alt='[Questioning]'}}}{\strong{[Questioning]}}}
\usage{
drake_envir(which = c("targets", "dynamic", "subtargets", "imports"))
}
\arguments{
\item{which}{Character of length 1, which environment
to select. See the details of this help file.}
}
\value{
The environment where \code{drake} builds targets.
}
\description{
Call this function inside the commands in your plan
to get the environment where \code{drake} builds targets.
Advanced users can use it to strategically remove targets from memory
while \code{\link[=make]{make()}} is running.
}
\details{
\code{drake} manages in-memory targets in 4 environments:
one with sub-targets, one with whole dynamic targets, one with
static targets, and one with imported global objects and functions.
This last environment is usually the environment
from which you call \code{\link[=make]{make()}}.
Select the appropriate environment for your
use case with the \code{which} argument of \code{drake_envir()}.
}
\section{Keywords}{

\code{\link[=drake_plan]{drake_plan()}} understands special keyword functions for your commands.
With the exception of \code{\link[=target]{target()}}, each one is a proper function
with its own help file.
\itemize{
\item \code{\link[=target]{target()}}: give the target more than just a command.
Using \code{\link[=target]{target()}}, you can apply a transformation
(examples: \verb{https://books.ropensci.org/drake/plans.html#large-plans}), # nolint
supply a trigger (\verb{https://books.ropensci.org/drake/triggers.html}), # nolint
or set any number of custom columns.
\item \code{\link[=file_in]{file_in()}}: declare an input file dependency.
\item \code{\link[=file_out]{file_out()}}: declare an output file to be produced
when the target is built.
\item \code{\link[=knitr_in]{knitr_in()}}: declare a \code{knitr} file dependency such as an
R Markdown (\verb{*.Rmd}) or R LaTeX (\verb{*.Rnw}) file.
\item \code{\link[=ignore]{ignore()}}: force \code{drake} to entirely ignore a piece of code:
do not track it for changes and do not analyze it for dependencies.
\item \code{\link[=no_deps]{no_deps()}}: tell \code{drake} to not track the dependencies
of a piece of code. \code{drake} still tracks the code itself for changes.
\item \code{\link[=id_chr]{id_chr()}}: Get the name of the current target.
\item \code{\link[=drake_envir]{drake_envir()}}: get the environment where drake builds targets.
Intended for advanced custom memory management.
}
}

\examples{
\dontrun{
isolate_example("contain side effects", {
plan <- drake_plan(
  large_data_1 = sample.int(1e4),
  large_data_2 = sample.int(1e4),
  subset = c(large_data_1[seq_len(10)], large_data_2[seq_len(10)]),
  summary = {
    print(ls(envir = parent.env(drake_envir())))
    # We don't need the large_data_* targets in memory anymore.
    rm(large_data_1, large_data_2, envir = drake_envir("targets"))
    print(ls(envir = drake_envir("targets")))
    mean(subset)
  }
)
make(plan, cache = storr::storr_environment(), session_info = FALSE)
})
}
}
\seealso{
\code{\link[=from_plan]{from_plan()}}
}
