Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

use_first

Only use the first element of a vector


Description

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

Usage

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

dont_stop(use_first(1:5))

assertive.base

A Lightweight Core of the 'assertive' Package

v0.0-9
GPL (>= 3)
Authors
Richard Cotton [aut, cre], Sunkyu Choi [trl], Ivanka Skakun [trl], Gergely Dar<c3><b3>czi [trl], Anton Antonov [trl], Hisham Ben Hamidane [trl], Anja Billing [trl], Aditya Bhagwat [trl], Rasmus B<c3><a5><c3><a5>th [trl], Mine Cetinkaya-Rundel [trl], Aspasia Chatziefthymiou [trl]
Initial release
2021-02-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.