use_first: Only use the first element of a vector

Description Usage Arguments Value Examples

View source: R/utils.R

Description

If the input is not scalar, then only the first element is returned, with a warning.

Usage

1
use_first(x, indexer = c("[[", "["), .xname = get_name_in_parent(x))

Arguments

x

Input that should be scalar.

indexer

Either double indexing, "[[" (the default) or single indexing "[".

.xname

Not intended to be used directly.

Value

If x is scalar, it is returned unchanged, otherwise only the first element is returned, with a warning.

Examples

1

Example output

$`use_first(1:5)`
<simpleWarning: Only the first value of 1:5 (= 1) will be used.>

assertive.base documentation built on Feb. 8, 2021, 9:06 a.m.