% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/resolver.R
\name{.determine_choices}
\alias{.determine_choices}
\alias{.determine_selected}
\alias{.determine_delayed}
\alias{.possible_choices}
\title{Evaluate delayed choices}
\usage{
.determine_choices(x, data)

.determine_selected(x, data, multiple = FALSE)

.determine_delayed(x, data)

.possible_choices(data)
}
\arguments{
\item{x}{(\code{character}, \code{quosure}, \verb{function(x)}) to determine \code{data} elements to extract.}

\item{data}{(\code{list}, \code{data.frame}, \code{vector})}

\item{multiple}{(\code{logical(1)}) whether multiple selection is possible.}
}
\value{
\code{character} containing names/levels of \code{data} elements which match \code{x}, with two differences:
\itemize{
\item \code{.determine_choices} returns vector named after data labels
\item \code{.determine_selected} cuts vector to scalar when \code{multiple = FALSE}
}
}
\description{
Evaluate delayed choices
}
\details{
\subsection{Various ways to evaluate choices/selected.}{

Function resolves \code{x} to determine \code{choices} or \code{selected}. \code{x} is matched in multiple ways with
\code{data} to return valid choices:
\itemize{
\item \code{x (character)}: values are matched with names of data and only intersection is returned.
\item \code{x (tidyselect-helper)}: using \link[tidyselect:eval_select]{tidyselect::eval_select}
\item \verb{x (function)}: function is executed on each element of \code{data} to determine where function returns TRUE
}

Mechanism is robust in a sense that it never fails (\code{tryCatch}) and returns \code{NULL} if no-match found. \code{NULL}
in \code{\link[=determine]{determine()}} is handled gracefully, by setting \code{NULL} to all following components of \code{picks}.

In the examples below you can replace \code{.determine_delayed} with \code{.determine_choices} or \code{.determine_selected}.
\itemize{
\item \code{character}: refers to the object name in \code{data}, for example

\if{html}{\out{<div class="sourceCode">}}\preformatted{.determine_delayed(data = iris, x = "Species")
.determine_delayed(data = iris, x = c("Species", "inexisting"))
.determine_delayed(data = list2env(list(iris = iris, mtcars = mtcars)), x = "iris")
}\if{html}{\out{</div>}}
\item \code{quosure}: delayed (quoted) \code{tidyselect-helper} to be evaluated through \code{tidyselect::eval_select}. For example

\if{html}{\out{<div class="sourceCode">}}\preformatted{.determine_delayed(data = iris, x = rlang::quo(tidyselect::starts_with("Sepal")))
.determine_delayed(data = iris, x = rlang::quo(1:2))
.determine_delayed(data = iris, x = rlang::quo(Petal.Length:Sepal.Length))
}\if{html}{\out{</div>}}
\item \verb{function(x)}: predicate function returning a logical flag. Evaluated for each \code{data} element. For example

\if{html}{\out{<div class="sourceCode">}}\preformatted{
.determine_delayed(data = iris, x = is.numeric)
.determine_delayed(data = letters, x = function(x) x > "c")
.determine_delayed(data = list2env(list(iris = iris, mtcars = mtcars, a = "a")), x = is.data.frame)
}\if{html}{\out{</div>}}
}
}
}
\keyword{internal}
