Learn R Programming

omnibus (version 1.2.15)

renumSeq: Renumber a sequence of numbers

Description

This function renumbers a sequence, which is helpful if "gaps" appear in the sequence. For example, consider the sequence {1, 1, 3, 1, 8, 8, 8}. This function will renumber the sequence {1, 1, 2, 1, 3, 3, 3}. NAs are ignored.

Usage

renumSeq(x)

Value

A vector.

Arguments

x

Numerical or character vector.

See Also

Examples

Run this code

x <- c(1, 1, 3, 1, 8, 8, 8)
renumSeq(x)

y <- c(1, 1, 3, 1, 8, NA, 8, 8)
renumSeq(y)

z <- c('c', 'c', 'b', 'a', 'w', 'a')
renumSeq(z)

Run the code above in your browser using DataLab