File: use_first.Rd

package info (click to toggle)
r-cran-assertive.base 0.0-9-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 476 kB
  • sloc: sh: 13; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (2)
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))
}