1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{use_first}
\alias{use_first}
\title{Only use the first element of a vector}
\usage{
use_first(x, indexer = c("[[", "["), .xname = get_name_in_parent(x))
}
\arguments{
\item{x}{Input that should be scalar.}
\item{indexer}{Either double indexing, \code{"[["} (the default) or
single indexing \code{"["}.}
\item{.xname}{Not intended to be used directly.}
}
\value{
If \code{x} is scalar, it is returned unchanged, otherwise
only the first element is returned, with a warning.
}
\description{
If the input is not scalar, then only the first element is returned,
with a warning.
}
\examples{
dont_stop(use_first(1:5))
}
|