50% off | Unlimited Data & AI Learning

Last chance! 50% off unlimited learning

Sale ends in


LICORS (version 0.2.0)

relabel_vector: Relabels a vector to consecutive labels

Description

This function relabels a vector to have consecutive - no missing in between - labels. Labels always start at 1 and increase by one.

For example, c(2, 2, 5) gets relabeled to c(1, 1, 2).

Usage

relabel_vector(vec, order = FALSE)

Arguments

vec

vector with labels

order

logical; if TRUE then new state labels are assigned by decreasing number of points in that state. That is, state ``1'' has the most points in the state, followed by state ``2'' etc.

Examples

Run this code
# NOT RUN {
TempVec <- c(10, 2, 1, 2, 2, 2, 10)
print(relabel_vector(TempVec))

print(relabel_vector(c(2, 2, 5)))
# }

Run the code above in your browser using DataLab