first: Identify the First Elements of Series of Repeated Values

View source: R/first.R

firstR Documentation

Identify the First Elements of Series of Repeated Values

Description

Identify the first elements of series of repeated values.

Usage

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

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

JVAdams/GLFC documentation built on Jan. 5, 2023, 12:59 a.m.