duplicateof: Find the index of the first occurrence of each value

View source: R/skUtils.R

duplicateofR Documentation

Find the index of the first occurrence of each value

Description

This replaces all values with the index of their first occurrence.

Usage

duplicateof(x, na.first = FALSE)

Arguments

x

A vector.

na.first

Logical value indicating whether to replace the first occurrence of each value with its index (if FALSE) or with NA (if TRUE).

Value

A vector of the length of x with each value representing either NA if it is the first occurrence of a unique value, or the index of the first instance of each value in x if it is a duplicated value.

Author(s)

Sercan Kahveci

Examples

duplicateof(c("a","b","a","k"))


Spiritspeak/skMisc documentation built on April 12, 2025, 5:40 a.m.