first: Gives the first non-missing element

View source: R/shorthands.R

firstR Documentation

Gives the first non-missing element

Description

Just a simple shorthand to get the first, non-missing argument per default. Can give more than one element and can include missing elements. The inverse of last().

Usage

first(x, n = 1, na.rm = TRUE)

Arguments

x

vector of which you want the first element

n

number of elements to take from the beginning

na.rm

whether to remove missings first, defaults to TRUE

Examples

first( c(NA,1:10) )
first( c(NA, 1:10), 2, TRUE )

rubenarslan/formr documentation built on July 6, 2024, 5:46 a.m.