first: Identify the First Elements of Series of Repeated Values

Description Usage Arguments Value Examples

View source: R/first.R

Description

Identify the first elements of series of repeated values.

Usage

1
first(x)

Arguments

x

A vector whose values will be explored for series of repeated values, can be character, numeric, or factor.

Value

An integer vector the same length as x, with a 1 for every element that is different than the one before it, and a 0 for every element that is the same as the one before it.

Examples

1
first(c(1, 2, 1, 2, 2, 1, 1, 3))

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.